The main features of H2 are:
- Very fast, open source, JDBC API
- Embedded and server modes; in-memory databases
- Browser based Console application
- Small footprint: around 2 MB jar file size
H2 | Derby | HSQLDB | MySQL | PostgreSQL | |
---|---|---|---|---|---|
Pure Java | Yes | Yes | Yes | No | No |
Memory Mode | Yes | Yes | Yes | No | No |
Encrypted Database | Yes | Yes | Yes | No | No |
From H2 Database Engine
server modes
in-memory databases modes
h2.start ();
in a Java program on the Java virtual machineEmbedded modes
In the past, there were many cases where the DB was directly accessed from Application using a library specific to the DB such as Oracle ** (such as using OracleLib in C ++).
With this method ** DB cannot be changed freely and products cannot be rearranged ** (Oracle version or MySQL version cannot be used)
→ In Java ** JDBC is solved! ** **
DB access basics
JDBC: ** SQL abstraction mechanism **
Access the specified DB (Oracle, etc.) based on JDBC jdbc_url
instead of hitting Oracle directly
A further ** abstraction ** by accessing the Oracle library by JDBC and accessing the RDB
If you read jdbc_url
and write h2, JDBC will access H2DB through the h2 library.
The app and RDB were directly connected (** tightly coupled ), but now the app and RDB are ** indirect ** via JDBC ( abstraction module **)! (Becomes ** loosely coupled **)
The app doesn't have to be involved in what the DB is, it only needs to know where to access it by URL (JDBC accesses the DB by URL)
No matter what the RDB is **, the app doesn't need to change it and JDBC will do it nicely **!
Recommended Posts