Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedding mysql in java desktop application

i am not clear about steps/configuration details about how i can embed mysql in a Java desktop application so that it(application) can be installed on any machine through a single executable file and doing so sets up database and also provides an exe to run the app.Till now i have built my app using netbeans and i have used mysql to set up database.plz guide me further.

like image 339
Andrew Avatar asked Aug 03 '10 03:08

Andrew


2 Answers

MySQL isn't an embedded database - the only JAR related to it is the JDBC driver. It requires a installation process, which might be able to be scripted via Java, but the process will definitely function outside of the Java application you intend it to support. Meaning, you can turn off your Java application but the MySQL service/daemon will still be running.

Only the libmysqld is embeddable.

There are embedded databases - SQLite, Firebird - and embedded databases made in Java - HSQL, Derby/(can't remember what it was called before). I believe SQL Server Compact Edition is embeddable, while SQL Server Express/MSDE is not. I don't know if Oracle has an embeddable version....

like image 171
OMG Ponies Avatar answered Oct 07 '22 21:10

OMG Ponies


I would strongly recommend H2. It is a very fast embedded database written in Java and I've found it easier to use than some of the others mentioned such as HSQL.

Edit:

On the H2 website, you can see a speed comparison of H2 vs Derby, HSQL, MySql, etc...

Here's information on how to backup the database.

like image 33
Jay Askren Avatar answered Oct 07 '22 21:10

Jay Askren