HSQLDB Database Connection Close Doesn’t Write to Disk - Solution
HSQLDB, the famous fast RDBMS written in Java, introduced a new feature which affects code ported over from previous versions. From version 1.7.2, in-process databases are no longer closed when the last connection to the database is explicitly closed via JDBC. Effectively your data is not written to disk even if you exit the program (say for database opened within application). Also it prevents opening the database next time around as a lock file (.lck) has been created to indicate that the data has not been commited to disk. There are two solutions to this issue.
You can either issue an explicit SHUTDOWN command through executeQuery. It will effectively shutdown the database and commit all data to disk.
A simpler way is to slightly alter your DriverManager.getConnection statement to ensure the database is closed after the last connection has been closed. This is what I use -
DriverManager.getConnection("jdbc:hsqldb:file:" + database + ";shutdown=true", "sa", "");
Filed under Database, How To, Java Software, RDBMS, Tech Note |
|
RSS 2.0 |
Trackback this Article
|
Email this Article
You may also like to read |





































July 16th, 2006 at 6:46 am
[...] http://blog.taragana.com/index.php/archive/hsqldb-database-connection-close-doesnt-write-to-disk-solution/ [...]