I have following datasource configuration in application.yml (Micronaut defaults):
datasources:
default:
url: jdbc:h2:mem:devDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
driverClassName: org.h2.Driver
username: 'user'
password: 'user'
schema-generate: CREATE_DROP
dialect: H2
jpa.default.properties.hibernate.hbm2ddl.auto: update
Hikari logs following:
21:09:01.750 [main] DEBUG com.zaxxer.hikari.HikariConfig - jdbcUrl.........................jdbc:h2:mem:devDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
Which seems to be correct. I attempt to connect to the database, and succeed. Hovever SHOW TABLES
returns nothing. When I add IFEXISTS=true
to url, I get the following error:
[90146][90146] Database "mem:devDb" not found, and IFEXISTS=true, so we cant auto-create it [90146-200].
The application is working - I can insert and fetch data, but I don't have a clue where the data is located, and how to access it outside the app.
What is the H2 default jdbc url in micronaut
For the hibernate-jpa
feature the default url is jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
.
...but I don't have a clue where the data is located, and how to access it outside the app.
The data is located in memory, only accessible by the application that created the in memory database. If you want any other process to access the data, your app that is using the in memory database would need to provide access to the data (like through an API, for example).
This is only a limitation because you are using an in memory database. Using an in memory database may not be the best solution for you if you need multiple processes connecting to the database.