Where does H2's Embedded Databases Store the data?
Read the FAQ:
Where are the Database Files Stored?
When using database URLs like
jdbc:h2:~/test
, the database is stored in the user directory. For Windows, this is usuallyC:\Documents and Settings\<userName>
orC:\Users\<userName>
. If the base directory is not set (as injdbc:h2:./test
), the database files are stored in the directory where the application is started (the current working directory). When using the H2 Console application from the start menu, this is<Installation Directory>/bin
. The base directory can be set in the database URL. A fixed or relative path can be used. When using the URLjdbc:h2:file:./data/sample
, the database is stored in the directory data (relative to the current working directory). The directory is created automatically if it does not yet exist. It is also possible to use the fully qualified directory name (and for Windows, drive name). Example:jdbc:h2:file:C:/data/test
The h2-*.jar
is just an engine (the code) of the database. It is read-only and it does not store any information. The data in H2 can be stored either in memory or on disk in a specified file. You are actually specifying one:
JDBC:h2:~/test/
You'll find your database in your home directory under test
subdirectory. Just copy these files to a home directory on another computer and H2 will find them as long as it uses the same URL.