Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Embedded database in Java app?

 
Lido Scaggsinsky
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm planning on putting together a (hopefully) simple client/server app which allows users to run a client and access the server app which hosts a database. I was going to use MySQL to handle the data, but I was wondering if there is a way I could bundle a simple database into the server app. That way I could distribute the client and server apps to anyone who has Java on their machine and they could hopefully use the program without having to set up and align a database program themselves. Thanks.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at http://hsqldb.org/
 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SQLite is another option, also used in PHP5. It can use a file, or memory if you omit the file in the connection string.
 
Masoud Kalali
Author
Ranch Hand
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You may also look at http://www.h2database.com/ it is faster and more feature rich with a nice web based administration console in a very small footprint.

thanks.
 
Lido Scaggsinsky
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. All of those look great. I didn't see any info on any of their sites that indicate that the db can be bundled with an application (in a jar file) and deployed with the application so the end user just double clicks the application file and it all works. Is there a term for that kind of thing?
 
Gaurav Arora
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you plan to build your application on JDK1.6 then you might also want to look at http://db.apache.org/derby/ and http://developers.sun.com/javadb/ since they come bundled with the JDK (and I think the JRE).
 
Lido Scaggsinsky
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I'd use 1.6, but most of the people who I'm writing this for use Mac and probably won't be upgrading to Leopard any time soon. I heard something on Java Posse about an open jdk 1.6 that someone is working on so I might give that a try.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
H2 is a commercial product, so you wouldn't be able to ship that with your app unless you negotiated a license.

SQLite is written in C, so shipping that would present some problems.

HSQLDB and Derby are your best options.
 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
SQLite is written in C, so shipping that would present some problems.

Actually, no.

You don't need the SQLite program itself, all you need is the JDBC driver. This has been released under the BSD license, so you can ship it without any problems.

Check here for the JDBC driver. There is a pure Java driver available.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lido Scaggsinsky:
Thanks. I'd use 1.6, but most of the people who I'm writing this for use Mac and probably won't be upgrading to Leopard any time soon. I heard something on Java Posse about an open jdk 1.6 that someone is working on so I might give that a try.


You do not need Java 6 in order to use Derby (a.k. JavaDB).

Derby only comes bundled with Java 6, but you can run it with Java 5 for sure. I know, as I am happily doing so. And, yes, I am using Mac OS X.

To use Derby in Java 5, the easiest thing to do is to go to a Windows box somewhere, find or install Java 6 and copy the bundled Derby from it. That's what I did. It is a pure Java database, so the version you find on Windows will work on Mac.

I think Derby will work with even older Java than Java 5, but I have not tried that.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Peter Chase:
To use Derby in Java 5, the easiest thing to do is to go to a Windows box somewhere, find or install Java 6 and copy the bundled Derby from it.

I think Derby will work with even older Java than Java 5, but I have not tried that.

It may be even easier to just download it from http://db.apache.org/derby/

According to http://db.apache.org/derby/docs/dev/getstart/ Java 1.4 is sufficient to run it.
 
Lido Scaggsinsky
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone. That helps a lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic