HSQLDB Database Connection Close Doesn’t Write to Disk - Solution
By Angsuman Chakraborty, Gaea News NetworkTuesday, January 17, 2006
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”, “”);
November 15, 2009: 5:43 pm
using shutdown like you said, made my application really really poor performance. If you are using jdbc based technology, the best for flushing the data to disk is closing the sql statement and creating a new one: stmt.executeQuery(”insert into …”); |
sgurin