Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 when a tests fails it can be convinient to be able to inspect the values in the in memory database. Is this possible? If so how? Our url is:

jdbc.url=jdbc:hsqldb:mem:testdb;sql.enforce_strict_size=true

The database is destroyed after each tests. But when the debugger is running the database should also still be alive. I've tried connecting with the sqldb databaseManager. That works, but I don't see any tables or data. Any help is highly appreciated!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
292 views
Welcome To Ask or Share your Answers For Others

1 Answer

In your unit test or in the @Before / setUp() method, you can add the following line to launch the HSQL Database Manager:


org.hsqldb.util.DatabaseManager.main(new String[] {
  "--url",  "jdbc:hsqldb:mem:testdb", "--noexit"
});

or for the improved Swing version with "more refinements" (but about same functionality)


org.hsqldb.util.DatabaseManagerSwing.main(new String[] {
  "--url",  "jdbc:hsqldb:mem:testdb", "--noexit"
});

The DB manager lets you inspect your schema and run SQL queries on the live in-memory database while the application is running.

Make sure to set a beakpoint or pause the execution one way or another if you want to check the state of your database at a specific line.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...