1

That is a conceptual question, Without Code exemple just to receive some idea for my project.

I Would like to deploy to my customer a JavaFx Desktop Application.

(This customer has little financial means).

My idea is to get a mysql Shared hosting (cheap like Godaddy or some other known and famous hosting)

But to connect to this database, if the connection not coming from the same localhost it is not allowed. But this shared hosting give me to connect through SSH connection. (I can connect to the mysql database with Sequel Pro if I provide the SSH Key )

My Idea is to connect via JDBC to this database with SSH connection with JSCH. See this post.

Is it ok to build an architecture of this type?

Someone has a better idea?

PS : To allow evolution of the App and to no having to distibutre it in all client PC, my idea is to install in all client PC dropbox and to share between all of the client a folder and to refresh the app in this folder when i have an evolution.

Community
  • 1
  • 1
shmoolki
  • 1,551
  • 8
  • 34
  • 57

1 Answers1

1

First, look at this: https://dzone.com/articles/singleton-design-pattern-%E2%80%93

You may want to create only one universal instance of the database and use it all across of your application.

    public class DataSource {

    private String url = "jdbc:mysql://localhost:3306/databasename";
    private String login = "root";
    private String password = "";
    private Connection connection;
    private static DataSource dataSource;

    private DataSource() {
        try {
            connection = DriverManager.getConnection(url,login,password);
            System.out.println("OK");
        } catch (Exception e) {
              System.out.println("NOT OK");
            e.printStackTrace();
        }
    }

    public Connection getConnection() {
        return connection;
    }

    public static DataSource getInstance() {
        if (dataSource == null) {
            dataSource = new DataSource();
        }
        return dataSource;
    }
}

I hope this help.

Oussama Ben Ghorbel
  • 2,132
  • 4
  • 17
  • 34