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.
Asked
Active
Viewed 1,869 times
2
-
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. – Feb 11 '12 at 14:06
-
1have you thought about sqlite? – juergen d Feb 11 '12 at 14:07
-
Is the DB for query only, or is intended to allow the user to update it? – Andrew Thompson Feb 11 '12 at 14:07
-
@bdares if i use Derby how to embed it with my application – user4o01 Feb 11 '12 at 14:08
-
@AndrewThompson he will update it – user4o01 Feb 11 '12 at 14:09
-
*"i can't use sqlite"* Please, (please, please) don't tell us what you "can't" do without explaining ***why***! People can give you far better help when they understand the reason behind constraints. Note also that @juergend would not be notified of the comment unless the comment is prefixed with '@PersonName'. – Andrew Thompson Feb 11 '12 at 14:10
-
If the DB is for update, it *cannot* be included in a Jar. Jars are effectively 'read only'. – Andrew Thompson Feb 11 '12 at 14:11
-
i can't use sqlite i need to use foreign keys – user4o01 Feb 11 '12 at 14:11
-
i will create empty tables and the user will have forms to insert delete update database , sorry – user4o01 Feb 11 '12 at 14:12
-
I have removed the "embedded" tag as that is for embedded systems, not for embedding a database in an application. – tinman Feb 11 '12 at 14:55
2 Answers
1
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.
0
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).

hlysig
- 1