• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

H2 database consule lockings

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I developed a java application, I can test it using the eclipse.
That application is working well with H2 DB , using it and releasing it.
I made a jar out of it, and I use it in a web application, running on tomcat.
The apache tomcat is locking my db.
When I run my application in java simple application, the db is released,
but when I run it on tomcat , the db is locked.
Why ?
Before returning the final answer from the jar, I do:

if(conn!=null)
if(!conn.isClosed())
conn.close();

Thanks
 
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi moshi,

I am curious to know why are you using H2 database rather than using mysql,which is most widely used open source database. In mysql you would not face the issue of database locking.

You can download mysql freely from the following url
 
moshi cochem
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone have an idea ?
thanks
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How does the web app use H2 - as a standalone server or in embedded mode? If it's embedded, then no other process can access it.
 
moshi cochem
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
But I close the connection, it is not enough ?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not if you're using embedded mode. For HSQLDB, the "Closing the Database" section of the documentation would be relevant; I'm sure H2 has something similar.
 
moshi cochem
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solve it by writing in the connection: FILE_LOCK=NO
Thanks.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have read the documentation for that feature at http://www.h2database.com/html/features.html#database_file_locking, and you do understand the potentially very bad consequences, right?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic