How to install a java application with MySQL database?

3

I'm developing a java desktop application, with java swing and MySQL database. But I need to install this application on multiple machines and I would like to know an easier way to do this, without having to install MySQL on all machines.

Is it possible to install an application using MySQL and not install it on each machine?

I did some research on various forums and suggested the following database: HSQLDB, SQLite, Derby, H2 and Firebird.

There is the possibility of hosting the database on some server on the internet.

I'd like to know how best to solve this problem.

    
asked by anonymous 23.11.2016 / 14:38

1 answer

4

Let's suppose that you have published your MySQL server on the bd.example.com host, on the default MySQL port (3306), and that the user is fulano , the password is senha123 , and the database is called minhabase .

In this case, you get java.sql.Connection by doing this:

String url = "jdbc:mysql://bd.example.com:3306/minhabase";
Connection conn = DriverManager.getConnection(url, "fulano", "senha123");

In addition, obviously you should have the MySQL JAR in the classpath. See more about this in my other response.

    
23.11.2016 / 14:55