I make a java application using netbeans that connect to database , but i have a problem , i want to embed mysql database with the executable jar file , so when i take this jar file and run it on any pc that doesn't have mysql server it will run with database , i thought about include the mysql-installer.exe and make a script to install the mysql server , but i can't find how to do that ,also i read about Connector/MXJ does it work if the user run the application and he does not have mysql server , any suggestion or article about this.
-
You could use Derby, which is a DB written entirely in Java. You'd just have to include the jar file and you'll have a fully-functional dbms.user684934– user6849342012-02-11 14:06:28 +00:00Commented Feb 11, 2012 at 14:06
-
1have you thought about sqlite?juergen d– juergen d2012-02-11 14:07:08 +00:00Commented Feb 11, 2012 at 14:07
-
Is the DB for query only, or is intended to allow the user to update it?Andrew Thompson– Andrew Thompson2012-02-11 14:07:59 +00:00Commented Feb 11, 2012 at 14:07
-
@bdares if i use Derby how to embed it with my applicationuser4o01– user4o012012-02-11 14:08:36 +00:00Commented Feb 11, 2012 at 14:08
-
@AndrewThompson he will update ituser4o01– user4o012012-02-11 14:09:04 +00:00Commented Feb 11, 2012 at 14:09
2 Answers
Derby is a pure-java DBMS. You bundle the derby jar with your program, just as you would any other library. This is a much cleaner way of ensuring your user has a db for your program, as you're not adding any dependencies.
Comments
Usually distributors don't include standalone databases, such as MySQL or Oracle, with their application. If needed, they provide SQL script to build the database and make the user type in the database host, username and password and make a script to build the database. If you want to "ship" the database with your application then I would consider more lightweight databases such SQLite (singe file database).