Inspect in memory hsqldb while debugging

后端 未结 8 2167
面向向阳花
面向向阳花 2020-12-12 13:18

We\'re using hdsqldb in memory to run junit tests which operate against a database. The db is setup before running each test via a spring configuration. All works fine. Now

8条回答
  •  温柔的废话
    2020-12-12 14:11

    The above accepted answer works perfectly only if the database name, username and password is untouched (testdb, SA, blank password).

    For custom database name, username and password you will get the following exception

    java.sql.SQLInvalidAuthroizationSpecException: invalid authorization specification - not found: SA

    Then, you have to connect manually.

    To connect directly to a non "default" DB use the following snippet

    org.hsqldb.util.DatabaseManager.main(new String[] {
      "--url",  "jdbc:hsqldb:mem:yourdbname", "--noexit",
      "--user", "dbusername", "--password", "dbpassword"
    });
    

    or for the improved Swing version

    org.hsqldb.util.DatabaseManagerSwing.main(new String[] {
      "--url",  "jdbc:hsqldb:mem:yourdbname", "--noexit",
      "--user", "dbusername", "--password", "dbpassword"
    });
    

    Before executing the above snippet update the following

    • yourdbname - Update yourdbname with real database name
    • dbusername - Update dbusername with your database username
    • dbpassword - Update dbpassword with your database password

提交回复
热议问题