This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error with accessing file!! Please help..

 
Malith Yapa
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
Raj Chila
Ranch Hand
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Malith,

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 ]
     
    Malith Yapa
    Ranch Hand
    Posts: 45
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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..
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic