How to see all tables in my h2 database at localhost:8082?

前端 未结 10 1064
误落风尘
误落风尘 2021-02-01 02:43

I use JDBC and created h2 database called usaDB from sql script. Then I filled all tables with jdbc.

The problem is that after I connect to usaDB at localhost:8082 I can

10条回答
  •  故里飘歌
    2021-02-01 03:13

    For the people who are using H2 in embedded(persistent mode) and want to "connect" to it from IntelliJ(other IDEs probably apply too).

    1. Using for example jdbc url as follows: jdbc:h2:./database.h2
    2. Note, that H2 does not allow implicit relative paths, and requires adding explicit ./
    3. Relative paths are relative to current workdir
    4. When you run your application, your workdir is most likely set to your project's root dir
    5. On the other hand, IDE's workdir is most likely not your project's root
    6. Hence, in IDE when "connecting" to your database you need to use absolute path like: jdbc:h2:/Users/me/projects/MyAwesomeProject/database.h2
    7. For some reason IntelliJ by default also adds ;MV_STORE=false. It disables MVStore engine which in fact is currently used by default in H2.
    8. So make sure that both your application and your IDE use the same store engine, as MVStore and PageStore have different file loyouts.
    9. Note that you cannot "connect" to your database if your application is using it because of locking. The other way around applies too.

提交回复
热议问题