Skip to content

Viewing Grails' In-Memory HSQLDB Database

Another example of “what I learned today.”

Thanks to act:ualise | technology for this.

import grails.util.Environment

class BootStrap {

  def init = {servletContext ->

    if (Environment.current == Environment.DEVELOPMENT) {
      //
      // don't forget to use the correct URL as set in DataSource.groovy
      // typically:  jdbc:hsqldb:mem:devDB
      // 
      org.hsqldb.util.DatabaseManager.main()
      ...

A cheap and cheerful way of looking at Grails’ in-built, transient in-memory database:

It’s no p6spy or autobase, but it’s good enough for now.

By the way: note the ‘new’ (Grails 1.1) way of determining the current execution environment. Much prettier than the old way.

[edit]

This makes it even easier:

org.hsqldb.util.DatabaseManager.main(['-url', 'jdbc:hsqldb:mem:devDB'] as String[])

Tags:

Java Enterprise Edition, JEE, JavaServer Pages, JSP, Tag Libraries, Servlets, Enterprise Java Beans, EJB, Java Messaging Service JMS, BEA Weblogic, JBoss, Application Servers, Spring Framework, Groovy, Grails, Griffon, Seam, Open Source, Service Oriented Architectures, SOA, Java 2 Standard Edition, J2SE