H2 is an embedded database written with Java. The database will be loaded in to application as a class library.

H2 database used in test cases

Testing database related functionalities needs preparing and cleaning data in database. Most database will persistent data to disk, and they usually takes time to start up and shut down.

H2 database won't persistent data in embedded mode, it also start up fast. Make it a very good choice for test.

H2 database an memory cache

Because all the data stay in memory, accessing is very fast, sometimes you can use it as a cache system.

Client local storage

For application that need local data storage, enforce user to install a database server is impossible. Instead, the product can embed H2 database to the application, just like SQLite.

H2 database in Server mode

H2 database is not only embeddable , it also can run as an independent server, listen on a network port, you can even deploy it on a cluster.

H2 database in embedded mode

The database running in application's process, performance is good , but can only be accessed by current process.

H2 database in in-memory mode

For the application that starts H2 database, it is running in embedded mode, at the same time, H2 database listen on TCP port for remote connection, for remote application, H2 database works in server mode.

Using this connection url to set in memory mode

 
jdbc:h2:~/test;AUTO_SERVER=TRUE
 
or
 
URL:jdbc:h2:mem:test