Thursday, January 24, 2008

Here is a powerful example by a co-worker on how to use the maven-groovy-plugin in your maven2 POMs. In this example Ron shows how you can embed a Groovy script in your POM to enforce a specific size of the resulting artifact (in this case an EAR).

This is very valuable because now you can do just about anything in your POM, including adding Java code as in this example (look under Using Java Classes).

However, with this power comes responsibility and you don't want to get in the habit of using this everywhere. Usually this is a red flag meaning you should create your own plugin to be reused by everyone. We should all be able to recognize the drawbacks of Copy+Paste.

Thursday, January 3, 2008

The following is how you can use DBVisualizer to connect to a GrailsHSQL Database. Grails uses Spring and Hibernate and its default database uses HSQLDB. So why would you want to view the Grails database? Maybe you are curious of how GORM works; debug your Domains; perhaps you don't trust Grails, or finally you might be a control freak. Or like me you are all of the above.

Update Datasource.groovyFirst, if you want to view the development database you need to change the url to not use an in-memory database because DBVisualizer will not have access to the Grails JVM memory. Open up the DataSource.groovy file and locate the development environment section and replace the existing url "jdbc:hsqldb:mem:devDB" with "jdbc:hsqldb:file:devDB;shutdown=true".

Start Grails>grails run-app

Create New Database Connection in DBVisualizerOpen up DBVisualizer (my version is 6.0.7) and create a new Connection (if you are unable to use DBVisualizer you can also use the HSQL Database Manager - see this post).

Type in a Connection Name: Grails Development

Choose HSQLDB as the DatabaseType

Choose HSQLDB embedded as your Driver using the hsqldb.jar located under your Grails home directory ($GRAILS_HOME/lib)

Update the Database URL to include your grails app base directory (jdbc:hsqldb:file:{your-grails-app-base-dir}/devDB). For me this was jdbc:hsqldb:file:/workspace/checkout/netcds-admin/devDB. Note that according to the HSQL document, Window users don't have to specify the C: drive.

Make sure your Userid is sa

Click Connect

View TablesThen on the left you should be able to see your tables under PUBLIC --> TABLE.

Special thanks to the Nabble users who responded to my question: Christian Laakmann and Helmut Denk.