H2 (DBMS)

H2 Database EngineFile:H2-logo.png

Initial release| December 2005; 20 years ago (2005-12)
Stable release|

1.4.197 / March 18, 2018; 8 years ago (2018-03-18)

Written in| Java
Operating system| Cross-platform
Type| Relational Database Management System
License| Eclipse Public License or Mozilla Public License 2.0
Website| www.h2database.com

H2 is a relational database management system written in Java. It can be embedded in Java applications or run in the client-server mode.[1]

The software is available as open source software Mozilla Public License 2.0 or the original Eclipse Public License.

## Contents

* 1 Main features
* 2 Challenges affecting durability of relational databases
* 3 Utilities
* 4 History
* 5 See also
* 6 References
* 7 External links

## Main features

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.[2]

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.

Two full text search implementations are included, a native implementation and one using Lucene.

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.[3]

The database supports protection against SQL injection by enforcing the use of parameterized statements. In H2, this feature is called 'disabling literals'.[4]

Since version 1.1.111, H2 in-memory database can run inside the Google App Engine.[5]

## Challenges affecting durability of relational databases

The H2 documentation explains in detail several ways in which problems in underlying hardware and in particular power systems can impact durability of relational databases.

According to the H2 documentation, such problems are related not only to the DB engine design, but also to the 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 is lost. Administrators have then to assess the common trade off between speed and data loss risks in the context of the business requirements and must carefully consider the design of the power supply and UPS of critical servers.

It is possible in some cases to force the storage to write cache frequently or even immediately using fsync which slows the writing process or one can accept that caching in the device buffer introduces some risk of data loss in case of power failure. The effectiveness of using fsync is limited by the fact that many HDD have write caching enabled by factory default in which case there is nothing about the design or settings of the database nor OS level commands that will be able to completely eliminate the chance of lost or inconsistent data in the event of a sudden power failure. Working with the OS and hardware settings to disable all caching so as to write data in real time can have significant impacts on performance in that only around 100 write operations per second would be achievable when using spinning disks.

The H2 documentation makes an effort to describe in detail [6] potential problems with durability (part of ACID) resulting from the potential data loss of committed transactions in case of a power failure.

Considering the hardware limitations regarding preservation of data in the event of sudden power loss and the ineffectiveness of approaches commonly employed by developers to prevent these sorts of losses, many database engines do not by default call FileDescriptor.sync() nor FileChannel.force() nor fsync or equivalents for every commit because they significantly degrade system performance without significantly increasing durability.

HSQLDB documentation references workarounds to a similar set of issues in their documentation.[7]

The Microsoft Knowledge Base describes the impact these issues, power failures, write caching, etc. can have on performance and durability.[8] The knowledge base discusses the trade offs between performance and the vulnerability of disk write caching as well as settings that an administrator can use to balance these.

## Utilities

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.

## History

The development of the H2 database engine started in May 2004, and first published in December 2005. The database engine was written by Thomas Mueller. He also developed the Java database engine Hypersonic SQL.[9] 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.[10]

## See also

* List of relational database management systems
* Comparison of relational database management systems
* Apache Derby
* HSQLDB

## References

1. ↑ "Presentation and use of H2 Database Engine". http://www.baptiste-wicht.com/2010/08/presentation-usage-h2-database-engine/.
2. ↑ "H2 Database supports PostgreSQL ODBC driver". http://www.theserverside.com/news/thread.tss?thread_id=46456.
3. ↑ "H2 Clustering". http://geowebcache.org/trac/wiki/external_h2db#H2clustering.
4. ↑ "SQL Injections: How Not To Get Stuck". http://thecodist.com/article/sql-injections-how-not-to-get.
5. ↑ "H2 Database on GAE". gaevfs. http://code.google.com/p/gaevfs/wiki/H2GAE.
6. ↑ "Advanced". http://www.h2database.com/html/advanced.html#durability_problems. Retrieved 30 October 2014.
7. ↑ "Chapter 9. SQL Syntax". http://www.hsqldb.org/doc/guide/ch09.html. Retrieved 30 October 2014.
8. ↑ "Slow Disk Performance When Write Caching Is Enabled". https://support.microsoft.com/kb/332023. Retrieved 21 December 2014.
9. ↑ Hypersonic SQL project page at SourceForge
10. ↑ "Write Your Own Database, Again". thecodist.com. http://thecodist.com/article/write-your-own-database-again-an-interview-with-the-author-of-h2.

## External links

* H2Sharp Ado.Net Provider for H2
* H2 database tutorial

0.00

(0 votes)

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Software:H2_(DBMS)&oldid=717745"