Introduction to H2 Database

What is H2 Database

H2 is an open source relational database management system written in Java. It can be used as an embedded database in Java applications or run in client-server mode. The software is available as open source software under Mozilla Public License 2.0 (MPL 2.0) or Eclipse Public License 1.0 (EPL 1.0).

Key Features of H2

Embedded Database

H2 can be embedded directly into Java applications without requiring a separate database server. This makes it very popular in development and testing environments.

Client-Server Mode

In addition to embedded mode, H2 also supports client-server mode, running as a standalone database server accessible by multiple applications simultaneously.

In-Memory Database

H2 supports in-memory database mode, where data is stored in memory and will be lost after restart. This is very useful for rapid testing and prototype development.

Multi-Database Compatibility

H2 is compatible with various SQL standards and can simulate the behavior of MySQL, PostgreSQL, Oracle, DB2, MS SQL Server, and other databases, facilitating database migration and testing.

Encrypted Database

H2 supports database encryption to protect sensitive data security.

H2 includes built-in full-text search functionality without additional configuration.

Zero Administration

As an embedded database, H2 requires no dedicated database administrator for maintenance.

H2 Application Scenarios

H2 is widely used in:

  • Embedded database for Java applications
  • Development and testing environments
  • Rapid prototype development
  • Unit testing and integration testing
  • Lightweight desktop applications
  • Learning SQL syntax

H2 Version History

H2 database engine development started in May 2004, first published in December 2005. The original developer, Thomas Mueller, also developed the Java database engine HSQLDB (originally named Hypersonic SQL).

License

H2 uses a dual license model:

  • Mozilla Public License 2.0 (MPL 2.0)
  • Eclipse Public License 1.0 (EPL 1.0)

System Requirements

  • Java Runtime Environment (JRE) 11 or higher
  • Can run on any operating system that supports Java, including Windows, Linux, macOS, and more