View content of H2 or HSQLDB in-memory database

后端 未结 11 1340
失恋的感觉
失恋的感觉 2020-12-02 05:27

Is there a way to browse the content of an H2 or an HSQLDB in-memory database for viewing? For example, during a debugging session with Hibernate in order to check when the

11条回答
  •  -上瘾入骨i
    2020-12-02 06:03

    In H2, what works for me is:

    I code, starting the server like:

    server = Server.createTcpServer().start();
    

    That starts the server on localhost port 9092.

    Then, in code, establish a DB connection on the following JDBC URL:

    jdbc:h2:tcp://localhost:9092/mem:test;DB_CLOSE_DELAY=-1;MODE=MySQL
    

    While debugging, as a client to inspect the DB I use the one provided by H2, which is good enough, to launch it you just need to launch the following java main separately

    org.h2.tools.Console
    

    This will start a web server with an app on 8082, launch a browser on localhost:8082

    And then you can enter the previous URL to see the DB

提交回复
热议问题