If you're using the Maven SQL Plugin from Codehaus to load your schema into an embedded on disk HSQLDB instance then you've probably encountered the following trace when your test cases against the database bomb:
java.sql.SQLException: Database lock acquisition failure: lockFile:
org.hsqldb.persist.LockFile@22c728ea[file =
/Users/akarasulu/Projects/local/factbook/db/target/factbookdb.lck,
exists=true, locked=false, valid=false, ] method: checkHeartbeat read:
2012-02-21 03:28:02 heartbeat - read: -102 ms.
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source)
at org.hsqldb.jdbc.JDBCDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
This is due to the fact that the maven sql plugin is not properly shutting down the embedded instance point to the on disk storage for whatever reason. The same problem does not occur when the database is in memory. To fix this issue just add another execution to the list of executions of the maven-sql-plugin to properly shutdown HSQLDB like so:
<execution>
<id>shutdown</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<sqlCommand>SHUTDOWN IMMEDIATELY</sqlCommand>
</configuration>
</execution>
</executions>
This should make the nasty lock based failures go away and your test cases against the database should run smoothly.