👉 Overview
👀 What ?
H2 is an open-source relational database management system written in Java. It can be embedded in Java applications or run in the client-server mode. The main features of H2 are that it is very fast, open source, JDBC API, small footprint: around 2 MB jar file size.
🧐 Why ?
H2 database is important because it's a lightweight, efficient and feature-rich option for application developers who require a database system that can be embedded within the application itself. It's especially useful in scenarios where deploying and managing a separate, standalone database server might be overkill. The speed and small footprint of H2 makes it a good choice for testing and prototyping applications.
⛏️ How ?
To use H2 database in your advantage, you can include it in your project as a Maven dependency or download and add the H2 jar file to your project. Once the H2 database is in your project, you can create a new instance of the database, create tables, insert data and query data using SQL commands in your Java code. It also provides a web console for managing the database.
⏳ When ?
The use of H2 database became popular in the mid-2000s as developers looked for lightweight, easy-to-use database systems that could be embedded in applications and distributed with them. It's especially popular in Java development due to its compatibility and ease of integration with the Java programming language.
⚙️ Technical Explanations
H2 database is implemented in Java and conforms to the JDBC (Java Database Connectivity) API, which is the standard Java API for database-independent connectivity between Java applications and a wide range of databases. H2 supports standard SQL, JDBC and ODBC. H2 is dual-licensed under the Modified BSD License and under the Eclipse Public License. It uses MVStore, or MultiVersion Concurrency Control(MVCC) Store, for data storage purposes, which is an append-only storage engine, meaning it writes new data to disk, and garbage collection is used to clean up old data. H2 also includes features such as full transaction support, database encryption, user-defined functions and stored procedures.