This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes H2 database consule lockings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "H2 database consule lockings" Watch "H2 database consule lockings" New topic
Author

H2 database consule lockings

moshi cochem
Ranch Hand

Joined: Nov 10, 2009
Posts: 91
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
Salil Vverma
Ranch Hand

Joined: Sep 06, 2009
Posts: 253

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


Regards
Salil Verma
moshi cochem
Ranch Hand

Joined: Nov 10, 2009
Posts: 91
Does anyone have an idea ?
thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41046
    
  43
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.


Ping & DNS - my free Android networking tools app
moshi cochem
Ranch Hand

Joined: Nov 10, 2009
Posts: 91
Hi,
But I close the connection, it is not enough ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41046
    
  43
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

Joined: Nov 10, 2009
Posts: 91
I solve it by writing in the connection: FILE_LOCK=NO
Thanks.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41046
    
  43
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: H2 database consule lockings
 
Similar Threads
Tomcat 5.5.23 - Code Compilation - Tomcat Stop/Re-Start
can't run query from java war
H2 database locking
H2 database - Connection is broken
Where to put jdbc jar files