Greymeister.net

Nice Tip on Getting HSQLDB Access in Grails

I run my development environment in Grails almost religiously on HQSLDB. Up until now the only downside was seeing the DB layout before I pushed up to another RDBMS. Now that I’m working with several different plugins, I want to see how they will effect my schema a little earlier. I found this post which seems to be linked from the Grails documentation, but I don’t really want anything fancy (actually, I just don’t want another bloated SQL Tool on my machine). However, I found this post which provided a solution that I like for a simple popup window with a query editor and schema browser. Now in my BootStrap.groovy file I have the following:

1
2
3
4
5
6
7
if("development".equals(GrailsUtil.environment)) {
       // ... various test data
      Thread.start{
          String[] databaseManagerOptions = ['--url', 'jdbc:hsqldb:mem:devDB', '--noexit'];
         org.hsqldb.util.DatabaseManagerSwing.main(databaseManagerOptions)
       }
}

You might notice the command line arguments I passed it, that’s because otherwise HSQLDB’s manager class decides it would be a good idea to call System.exit() when you close the UI. I completely disagree in this case :) Now I can see what the schema looks like and verify that my domain objects are interacting the way I expected them to.