H2 Console Cant see tables created by JAVA

后端 未结 7 1819
北海茫月
北海茫月 2021-02-02 11:18

I have downloaded the H2 console from http://www.h2database.com/html/download.html
and I have configured the URL in my jdbc.properties file
to jdbc:h2

相关标签:
7条回答
  • 2021-02-02 11:55

    Had the same Problem.

    This solved it for me: Why is my embedded h2 program writing to a .mv.db file

    Just added ;MV_STORE=FALSE and ;MVCC=FALSE to the jdbc url and everything worked just fine.

    0 讨论(0)
  • 2021-02-02 11:56

    You can also avoid this problem by using the same version between H2 console and your Java code.

    This is how I solved this same issue here.

    0 讨论(0)
  • 2021-02-02 11:58

    I have used the below and I see my table get created.


    spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
    spring.h2.console.enabled=true
    spring.h2.console.path=/h2console
    spring.datasource.username=sa
    spring.datasource.password=
    spring.datasource.driverClassName=org.h2.Driver
    spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
    
    0 讨论(0)
  • 2021-02-02 12:02

    Based on your question, it doesn't look like you fell victim to this particular pitfall, but this thread ended up helping me nail down the issue, so I am recording the solution here for posterity since it may help others with the same problem.

    I also found that when I tried to open my database with the H2 console that I got what appeared to be a blank H2 database (basically, just an INFORMATION_SCHEMA table). While double-checking that I got the name of the DB correct (mydb.mv.db), I discovered that the H2 console had created a second database file, mydb.mv.db.mv.db. Odd.

    It turns out that the H2 Console expects you to omit the suffix .mv.db from the filename. Since I hadn't, it was looking for mydb.mv.db.mv.db. Changing the JDBC string to jdbc:h2:mydb solved the problem and I could then open the file from the H2 Console.

    0 讨论(0)
  • 2021-02-02 12:04

    This is how you enable memory enable database using h2 module. You need to ensure the following things

    1. You had class that has @Entity annotations.
    2. you need to enable the following in application.properties file spring.h2.console.enabled=true
    3. Run Spring Boot and enter the following URL localhost:8080/h2-console
    4. This will show a connection screen. Enter the following changes in the JDBC URL: -> jdbc:h2:mem:testdb 5.Hit the connection button

    Salam

    0 讨论(0)
  • 2021-02-02 12:04

    Add Annotation @EntityScan("packageName") in main class

    0 讨论(0)
提交回复
热议问题