简体   繁体   中英

H2 tables not showing up in IntelliJ for Jhipster generated project

So I generated a new Spring boot application using jhipster. Upon navigating to the H2 console, the following information is shown.

在此处输入图像描述

I am able to login, and I can verify tables exist. 在此处输入图像描述

Next, I copy the link, jdbc:h2:file:./target/h2db/db/ikdoemee and try to connect to the H2 database using IntelliJ which shows successful . 在此处输入图像描述

However, the IntelliJ database view isn't showing any tables. 在此处输入图像描述

I tried adding the following parameters to my JDBC url, but no tables show up.

jdbc:h2:file:./target/h2db/db/ikdoemee;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1 ;DATABASE_TO_UPPER=false

Why am I unable to get my tables visible in IntelliJ?

My.h2.server.properties is

#H2 Server Properties
0=JHipster H2 (Disk)|org.h2.Driver|jdbc\:h2\:file\:./target/h2db/db/ikdoemee|ikdoemee
webAllowOthers=true
webPort=8082
webSSL=false

EDIT: My target folder: 在此处输入图像描述

You need to activate h2 "Automatic Mixed Mode" by changing the spring.datasource.url of the application-dev.yml file. example URL: jdbc:h2:./target/h2db/db/'PROJECTNAME';AUTO_SERVER=TRUE

The URL for the connection to the h2 database should look like that:

jdbc:h2:/home/'USERNAME'/IdeaProjects/'PROJECT'/target/h2db/db/'PROJECTNAME';AUTO_SERVER=TRUE

if that doesn't work try also to delete the target folder and refresh the h2 connection

The only solution that worked for me at the moment is to put the direct path to the file in Path field without extension. After that I could see my tables in IDEA.

click to preview settings

Note:

Don't forget to also add parameter AUTO_SERVER=TRUE to datasource.url , as pointed out by @Unknown_Energy .

My apps versions:

  • Idea 2018.3.5 UE
  • h2 1.4.197
  • h2 base name: demo.mv.db

this bug is related to these issues:

When running the application, the log will show something like nwconfig.DatabaseConfiguration 1: H2 database is available on port 18080. Then change Connection Type to Remote and port to the port just showed, append the db file location to the url (with out extension) just like ./build/h2db/db/projectname , User will be the ProjectName.

The final url will like jdbc:h2:tcp://localhost:18080/./build/h2db/db/projectname

This worked for me, I'm not a English native speaker, sorry for my poor English.

To resolve this issue I installed Buddy JPA plugin. It created profile automatically and I compared it with mine. the difference was in parameter DB_CLOSE_ON_EXIT=FALSE I tried it with manually created profile and it works as well. The result link is:

jdbc:h2:file:./work/h2db;DB_CLOSE_ON_EXIT=FALSE

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