When i try to access my HSQLDB database through my web app sometimes i get the following error :-
The database is already in use by another process: org.hsqldb.persist.NIOLockFile@b857bc59[file =/home/malith/www/data/db.lck, exists=true, locked=false, valid=false, fl =null]: java.lang.Exception: checkHeartbeat(): lock file [/home/malith/www/data/db.lck] is presumably locked by another process.
What could be causing it? upto my knowledge HSQLDB allows multiple connections . So what other process could be using it?? Is it something wrong with the server i use.. It's a Apache 2.0.59 + Tomcat 5.5.23 .. Pleeeeease help... Oh and this error doesn't occur when i'm running the web app at my home tomcat..
One more thing, Is it necessary to call the everytime i connect to the database.. Or is just enough that i call it from within the constructor once...
Guys i really really need some help.. Thanks in advance..
HSQL DB allows you to connect to the Db in different ways by passing specifying the datasource as a file db , or a server or in memory.
The reason why you are seeing this problem is that every time you make a file connection a .lck file is created indicating that the db is locked.
Simply delete this .lck file and restart your app and it should work...but if it is happening every time then do the following.
If you are the only one who is accessing this database then every time you are closing the application you need to take the following steps to ensure a clean exit.
get all the existing connection Uri's with this call DatabaseManager.getDatabaseURIs();
then for each URI call on the DatabaseManager.closeDatabases(i);
Finally call DriverManager.deregisterDriver(DriverManager.getDriver()); to deregister the driver.
hope this helps [ July 25, 2007: Message edited by: Raj Chila ]
Joined: Jan 17, 2007
Thanks raj.. But i actually figured that the problem was that the server i 'm using was clustered for two instances.. So when one JVM creates the database the other JVM doesn't have access to it.. That way only one of two requests would be processed.. Thanks for your tip anyway..