I am trying to use H2 (embedded mode) to package in a ZIP file (which also contains my Java app JAR
). When the user runs the JAR
, it will use the H2 database that "shipped" with the ZIP file.
How do I configure a username and password for the H2 database that can be used by my JAR for accessing data? For instance, I might want to create a username called myapp
with a password of 12345
and supply that to my app's JDBC connection string.
But in order for JDBC to authenticate my app against the H2 DB, I first need to set up the myapp
user in the first place. How do I do this? Thanks in advance!
If you try to connect to a database that does not exist, it is created. See http://www.h2database.com/html/tutorial.html#creating_new_databases
The juicy bit:
The user that created the database automatically becomes the administrator of this database.