|Stable release||1.3.176 / April 5, 2014|
|Type||Relational Database Management System|
|License||Eclipse Public License or a modified version of Mozilla Public License 1.1|
H2 is a relational database management system written in Java. It can be embedded in Java applications or run in the client-server mode. The disk footprint (size of the jar file) is about 1.5 MB.
The software is available as open source software under modified versions of the Mozilla Public License or the original Eclipse Public License. The modification of the MPL is a shorter file header and the license name.
A subset of the SQL (Structured Query Language) standard is supported. The main programming APIs are SQL and JDBC, however the database also supports using the PostgreSQL ODBC driver by acting like a PostgreSQL server.
It is possible to create both in-memory tables, as well as disk-based tables. Tables can be persistent or temporary. Index types are hash table and tree for in-memory tables, and b-tree for disk-based tables. All data manipulation operations are transactional. Table level locking and multiversion concurrency control are implemented. The 2-phase commit protocol is supported as well, but no standard API for distributed transactions is implemented. The security features of the database are: role based access rights, encryption of the password using SHA-256 and data using the AES or the Tiny Encryption Algorithm, XTEA. The cryptographic features are available as functions inside the database as well. SSL / TLS connections are supported in the client-server mode, as well as when using the console application.
A simple form of high availability is implemented: when used in the client-server mode, the database engine supports hot failover (this is commonly known as clustering). However, the clustering mode must be enabled manually after a failure.
H2 documentation describes problems with durability (part of ACID), which can cause data loss of committed transactions in case of a power failure. According to the documentation these problems are not limited to H2, but are also found in some other relational databases.
According to documentation, the system doesn't call FileDescriptor.sync() nor FileChannel.force() nor fsync for every commit because they significantly degrade system performance: only about 100 write operations per second would be achievable when using spinning disks.
Another reason for not using fsync is that many HDD have write caching enabled by factory default.
According to the H2 documentation, such a problem is related not only to the DB engine design, but also to the enabled storage caching mechanism. As storage devices use write cache in order to increase speed, in a situation of power failure, data in the device's cache are lost. Administrators have then to assess the common trade off between speed and data loss risks in the context of the business requirements. Either one forces the storage to write cache frequently or even immediately using fsync and slows the writing process or one accepts caching in the device buffer and risk data loss in case of power failure.
From the HSQLDB documentation: "To avoid this, you can set write delay down to 10 milliseconds. In practice, a write delay of 100 milliseconds provides better than 99.9999% reliability with an average one system crash per day, or 99.99999% with an average one system crash per 6 days."
The documentation advises to use the additional commands SET WRITE_DELAY and CHECKPOINT SYNC to ensure durability. These commands are available to administrators only.
An embedded web server with a browser based console application is included, as well as command line tools to start and stop a server, backup and restore databases, and a command line shell tool.
The development of the H2 database engine started in May 2004, but it was first published in December 2005. The database engine was written by Thomas Mueller. He also developed the Java database engine Hypersonic SQL. In 2001, the Hypersonic SQL project was stopped, and the HSQLDB Group was formed to continue work on the Hypersonic SQL code. The name H2 stands for Hypersonic 2, however H2 does not share code with Hypersonic SQL or HSQLDB. H2 is built from scratch.
- List of relational database management systems
- Comparison of relational database management systems
- Apache Derby
- "Presentation and use of H2 Database Engine".
- "Jar File Download". Retrieved 24 April 2014.
- "OpenLogic Exchange Package Listing".
- "H2 Database supports PostgreSQL ODBC driver".
- "H2 Clustering".
- "SQL Injections: How Not To Get Stuck".
- "H2 Database on GAE". gaevfs.
- Hypersonic SQL project page at SourceForge
- "Write Your Own Database, Again". http://thecodist.com.