I've written some code to automatically create the db tables if they are not present.
What it basically does is this:
1) Setup the hibernate Configuration
2) Call buildSessionFactory() to get a session factory
3) Attempt a simple query on the db
4) if the query fails, use SchemaExport.create() using the same hibernate config to create the tables
This was working fine. In the production code it's used fairly rarely, but the unit tests depend on it. All of the sudden this stopped working and now I get an exception when trying the SchemaExport. It seems to be complaining that the HSQL DB is already in use, presumably because of the query I tried before the SchemaExport.
I've spent a couple of days trying to figure out what changed with no success. I've tried issuing a SHUTDOWN to the db with mixed results. Also tried adding the hibernate.connection.shutdown property to the configuration.
Has anybody ever seen something like this before? The really mystifying part is that it used to work just fine and stopped all of the sudden.
Thanks,
Fabian
Hibernate version:
I believe we're still using Hibernate 2.
Full stack trace of any exception that occurs:
java.sql.SQLException: The database is already in use by another process: org.hsqldb.NIOLockFile@977267fd[file =C:\eclipse3.2\junit-workspace\holdings_db.lck.lck, exists=true, locked=false, valid=false, fl =null]: java.lang.Exception: The process cannot access the file because another process has locked a portion of the file : C:\eclipse3.2\junit-workspace\holdings_db.lck.lck
at org.hsqldb.jdbc.jdbcUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
at org.hsqldb.jdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:66)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:76)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.acquireResource(C3P0PooledConnectionPool.java:66)
at com.mchange.v2.resourcepool.BasicResourcePool.assimilateResource(BasicResourcePool.java:787)
at com.mchange.v2.resourcepool.BasicResourcePool.acquireUntil(BasicResourcePool.java:548)
at com.mchange.v2.resourcepool.BasicResourcePool.access$000(BasicResourcePool.java:35)
at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:972)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:148)
Name and version of the database you are using:
HSQL 1.7