Java Embedded Databases Comparison

Java Embedded Databases Comparison

Either

  • HSQLDB - Used by OpenOffice, tested and stable. It's easy to use. If you want to edit your db-data, you can just open the file and edit the insert statements.

or

  • H2 - Said to be faster (by the developer, who originally designed hsqldb, too)

Which one you use is up to you, depending how much performance and how much stability you need.

The developer of H2 has put up a nice performance evaluation:

http://www.h2database.com/html/performance.html

Which is best embedded database for java?

Either

HSQLDB - Used by OpenOffice, tested and stable. It's easy to use. If you want to edit your db-data, you can just open the file and edit the insert statements.
or

H2 - Said to be faster (by the developer, who originally designed hsqldb, too)
Which one you use is up to you, depending how much performance and how much stability you need.

The developer of H2 has put up a nice performance evaluation:
http://www.h2database.com/html/performance.html

see more

Embedded Java Databases for Large Data Sets

The worry you'll have, which will become less of a concern as time goes on, is whether you'll have users with inadequate memory to handle those millions of rows in an embedded database.

When everyone has a 64 bit operating system and 8GB of RAM or more you'll be in the clear.

I agree that SQLLite or Hypersonic can handle it as long as there's sufficient memory. I'd wonder what each will do for those situations where memory becomes scarce.

You certainly have the option to run Hypersonic in server mode and let it keep data on disk. This might be an attractive alternative, especially as SSDs become prevalent. You can keep the convenience of not requiring a database install and still manage large data sets without exhausting available RAM.

What will be the best embedded database to be used with a small Java desktop application?

I'd suggest HSQLDB. Looking at tutorials of frameworks like Spring and Hibernate, they tend to use HSQLDB as an example of how to use an embedded database with them.

You can use JPA with it, I've personally tried with Hibernate and have had some great results. It's used in projects such as OpenOffice and Mathematica, so that should speak of its quality.

HSQLDB fits 4 of your 5 requirements. Maybe 5 of 5, only because I don't use Netbeans as my IDE. But I'm sure you can try it yourself.

How can a Java app create and manage a DB locally for a user?

Use a database written in pure Java that you can include with your app. H2 and Derby are two such products. The database files can be created and stored on the user’s local machine.

Personally, I use and recommend H2.

Best Embedded SQL DB for write performance?

This benchmark from db4o might be helpful. It includes, JavaDB (Built on top of Derby), HSQLDB, SqlLite.

It seems HSQLDB out-performs its counterparts, especially when writing is concerned. H2, as a successor of HSQLDB, is faster than HSQLDB in both read and write with optimizing, clustering, transaction isolation features.

Highest Performance Database in Java

You could try something like Prevayler (basically an in-memory cache that handles serialization and backup for you so data persists and is transactionally safe). There are other similar projects.
I've used it for a large project, it's safe and extremely fast.

If it's the same set of 20,000 objects, or at least not 20,000 new objects every 5 seconds but lots of changes, you might be better off cacheing the changes and periodically writing the changes in batch mode (jdbc batch updates are much faster than individual row updates). Depends on whether you need each write to be transactionally wrapped, and whether you'll need a record of the change logs or just aggregate changes.

Edit: as other posts have mentioned Prevayler I thought I'd leave a note on what it does:
Basically you create a searchable/serializable object (typically a Map of some sort) which is wrapped in a Prevayler instance, which is serialized to disk. Rather than making changes directly to your map, you make changes by sending your Prevayler instance a serializable record of your change (just an object that contains the change instruction). Prevayler's version of a transaction is to write your serialization changes to disk so that in the event of failure it can load the last complete backup and then replay the changes against that. It's safe, although you do have to have enough memory to load all of your data, and it's a fairly old API, so no generic interfaces, unfortunately. But definitely stable and works as advertised.



Related Topics



Leave a reply



Submit