H2 Database Engine

The creator of HSQL has created a new Java database called H2. We have tried it!

Here is the introduction to H2, from its website:

[…]The main feature of H2 are:

* Very fast, open source, JDBC and ODBC API
* Embedded, server and cluster modes; in-memory databases
* Browser based Console application
* Small footprint: around 1 MB jar file size

H2 seems doing its work very well: it installs in a snap, is very easy to use and integrate in Java webapps.

The maximum number of rows per table is 2’147’483’648, which is a good limit. There is some troubles managing big files (normal FAT32 limit is 4GB), but there is a workaround.

The web console is very well done, with auto-competition and so on.

It is still a young product: there areĀ  some nasty bugs, but the Author, Thomas Muller fix them very fast. So, if you need a embedded DB for some simple tests, H2 is a good bet.

We also read on the motivationsĀ  (bold is ours):

A few reasons using a Java database are:

  • Very simple to integrate in Java applications
  • Support for many different platforms
  • More secure than native applications (no buffer overflows)
  • User defined functions (or triggers) run very fast
  • Unicode support

Some people think that Java is still too slow for low level operations, but this is not the case (not any more). In general, the code can be written a lot faster than using C or C++. Like that, it is possible to concentrate on improving the algorithms (that make the application faster) rather than porting the code and dealing with low level stuff (such as memory management or dealing with threads). Garbage collection is now probably faster than manual memory management.

A lot of features are already built in (for example Unicode, network libraries). It is very easy to write secure code because buffer overflows can not occur. Some features such as the reflection mechanism can be used for randomized testing.

Java is also future proof: A lot of companies support Java, and it is now open source.

This software does not rely on many Java libraries or other software, to increase the portability and ease of use, and for performance reasons. For example, the encryption algorithms and many library functions are implemented in the database instead of using the existing libraries. Libraries that are not available in open source Java implementations (such as Swing) are not used or only used for specific features.

Leave a Reply