BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News H2 1.0 Database by Hypersonic Creator is Out

H2 1.0 Database by Hypersonic Creator is Out

HSQLDB creator Thomas Mueller has released 1.0 final of H2, his pure Java database successor to HSQLDB. H2's focus is to be best database for the lower end (low number of concurrent connections, embedded usage).    H2's features are comparable to MySQL and PostgreSQL; it has views, subqueries, triggers, clustering, role based security, encryption, user defined functions, disk and in-memory usage, embedded and client-server usage, referential integrity, scrollable result sets, schema support, transaction isolation. There are a few tools like the browser based Console application (now with auto-complete).  A few things are still missing: H2 currently only offers table-level locking, full outer joins are not supported yet, the ODBC driver is only 'experimental' so far, and the standard API for distributed transactions (two-phase commit) is incomplete, however for most use cases these may not be critical.

"It makes sense to use H2 whenever you need an embedded database in your Java application. Or if you need a database for regression testing, or to learn SQL or the JDBC API. Or if you need a high-performance database," H2 creator Thomas Mueller told InfoQ., who also made a comparison to HSQLDB and Derby:
There are some architecural problems in HSQLDB that are hard to fix or work around: The opening / closing a database in HSQLDB can be very slow if the database is big, because the whole database is always backed up. HSQLDB doesn't offer any transaction isolation. Some operations on HSQLDB are limited by the memory (result set size, transaction size, BLOB / CLOB size). The current query optimizer of HSQLDB is really bad in my opinion. A lot of the higher level features are not supported (updatable result sets, encrypted database, data compression, computed columns, linear index, hash index, multi-dimensional index, linked table). In my view the source code of H2 is cleaner than that of HSQLDB. But the jar file of H2 is a bit bigger than the one of HSQLDB (1 MB jar file size instead of 600 KB). And for some very simple operations HSQLDB is currently a little bit faster.

The comparison between H2 and Derby / Java DB is also quite interesting. The biggest difference is, in my view, speed. Derby is just really slow (like, ten times slower) for simple operations. This didn't change since it was a standalone company (Cloudscape Inc.). In my view this performance problem of Derby is an architectural problem, and I don't think it can be changed without re-writing a large part of the code. But that's just my opinion. I know, many people will say that the speed depends on the the application and that it's easy to write a benchmark that favors one product. But my performance tests are open source, fair (in my view), and based on known algorithms like TPC-A and TPC-C (modified for the single-user case). There are a few other problems with Derby, like each table and index is stored in it's own file in Derby. Feature-wise, H2 and Derby are probably at about the same level.
There aren't plans to merge H2 with HSQLDB due to the licensing. HSQLDB is available on a BSD license whereas H2 is has a copy of the Mozilla Public License. Thomas clarified:
The main difference to the BSD license is: Under the BSD license, anybody can take the source code, change it and sell it without providing the changes back to the community. This is not possible under the MPL. It is still commercial-friendly (more friendly than GPL): You can use H2 in a commercial application without having to provide the source code of your application. You only have to provide changes in H2 code (for example, bugfixes). If a company could also add a new indexing mechanism (I don't know, for example an R-Tree index) to H2 and sell the resulting product without having to provide the source code for this added feature. The MPL is similar to the LGPL, but in my view clearer in what you can do and what not, at least for Java applications. There is still the option to dual- or tripple-license the code, for example if somebody needs the LGPL license.
Going forward, Thomas will be focused on testing, bugfixing, but also "performance optimizations, improving concurrency and compatibility with other databases."   Thomas doesn't have any plans to commercialize his work but may consider offering support should sufficient interest arise.

Rate this Article

Adoption
Style

BT