Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.6k views
in Technique[技术] by (71.8m points)

What is the H2 default jdbc url in micronaut

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...