简体   繁体   中英

Tables from H2DB file doesn't appear in IDEA, but shows in H2 console

I have some simple Spring Boot project with H2db file with location./dbs/database.mv.db (./ from my project's dir). application.properties is:

spring.datasource.url=jdbc:h2:./dbs/database;AUTO_SERVER=TRUE
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=password
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=update

# Enabling H2 Console
spring.h2.console.enabled=true
# Custom H2 Console URL
spring.h2.console.path=/h2

So, Spring Boot App got it and can manipulate with table in it, stores data in DB file. Console by localhost:8080/h2 show it too. But I have problem with IDEA: IDEA got connection only by absolute name (Embedded source with url jdbc:h2:~/Documents/projects/java/seccomp/dbs/database;AUTO_SERVER=TRUE). But in this case IDEA show me no tables at all. I'm confused, probably App creates some table in target directory? No, if I have removed my mv.db file from.dbs/ it will create again after data manipulation from Application.

Why Application and H2 Console show me tables, but IDEA doesn't?

With the ./dbs/database;AUTO_SERVER=TRUE you are specifying the path to a database file which is resolved relative to the corrent working direcrory where you program is run. With the ~/Documents/projects/java/seccomp/dbs/database - you are specifying it relatively you user home. Make sure you are actually specifying the same path in these both cases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM