Roledenez
Roledenez

Reputation: 761

How to copy MySQL database with java jar file

my MYSQL DB can find in wamp\bin\mysql\mysql5.6.12\data path called cament_factory_db I copy that cament_factory_db folder to my netbeans project folder and changed the connection string jdbc:mysql://localhost:3306/cement_factory_db to jdbc:mysql://cement_factory_db re-compiled it. then compiler says

Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. Communications link failure

I want to create portable jar file with MYSQL data base? How does it do ?

Upvotes: 1

Views: 1736

Answers (2)

Pantelis Natsiavas
Pantelis Natsiavas

Reputation: 5369

MySQL is not a file based database management system. It always requires a MySQL server to which the application would connect to. If you want to distribute an application which uses a database, you have two options.

  1. Use a flat file based database. Then you could add the flat file to your application's distribution. Examples of such database management systems are (SQL Server Compact, SQLite, HSQLDB,H2 and Derby).

  2. Use a database server architecture. This means that your distributed applications would not transfer the database with them, but they would connect to your database hosted somewhere over the internet. As a server database, you could use MySQL which follows this architecture.

If I get it right, the first approach would be more suitable for you.

Hope I helped!

Upvotes: 4

Roledenez
Roledenez

Reputation: 761

Finally I found the answer. if I use mysql database, I have to install it in every computer that my program run. otherwise I have to use embedded database like sqlite that can embedded with jar file

Upvotes: 2

Related Questions