views:

38

answers:

2

I'm debeloping a Java Swing application, which persists the information through Hibernate, currently using PostgreSQL. Now, I would like to simplify the database setup on the client and I'm thinking about single file databases. The database I'm using is rather small and simple, so there are no special requirements. I'm only asking for one that is stable and reliable.

What solutions are there available which are compatible with Hibernate? The final application shouldn't have any installation steps such as installing a database server or so. The perfect scenario would be a .zip file that is unzipped and everything is ready to go, like Eclipse does.

Thanks!

+2  A: 

Java database such as JavaDB (aka Derby), HSQLDB or the more recent H2 (by the original author of HSQLDB) in embedded mode are all possible candidates. Between them JavaDB tend to be considered as the most robust (full ACID, robustness against failures, unlimited db size etc) and would be my choice.

Here is a quick summary of the reasons:

  • H2 is very interesting and I use it for testing (its compatibility mode feature is really great) but I'm not sure of its maturity for production use.

  • H2 and HSQLDB are faster than Derby because they do not sync data to disk on commit - while Derby does. So performance comes from the lack of Durability. If you change this behavior, they all hit the some bottleneck: disk IO.

  • HSQLDB only supports dirty read, transactions see uncommitted values from other transactions.

  • HSQLDB is not fully Atomic, a transaction can be partially(WTF?) committed

  • Derby is more powerful, has specs compliant drivers, scales well.

Don't misinterpret me, I'm not saying HSQLDB is bad but you need to know what you're dealing with and in which context/application. Sometimes speed is more important (e.g. for unit testing), and sometimes it is data integrity. If you are in the latter case, Java DB is IMO a better choice.

Some of the references below are 2/3 years old but I'm not aware of any revolution. If I made some mistake, let me know, I'll be happy to update my answer to make it accurate.

References

Pascal Thivent
Reasons to choose Java DB over HSQLDB?
Hectoret
@Hectoret: See my full update.
Pascal Thivent
+1  A: 

I have used HSLQDB in conjunction with hibernate for long. It is really fast, easy to use application for basic small db requirements.

Tushar Tarkas