I'm attempting to make use of the H2 database from the Java application. I produced the database and it is tables with the H2 Console after which I attempt for connecting from Java using

Connection disadvantage = DriverManager.getConnection("jdbc:h2:~/dbname","username","password")

However get the following error:

Exception in thread "primary" org.h2.jdbc.JdbcSQLException: Database might be already being used: "Locked by another process". Possible solutions: close other connection(s) make use of the server mode [90020-161]

I attempted to remove the dbname.lock.db file but it's instantly re-produced.

How do i unlock the database for doing things from the java program?


H2 continues to be running (I'm able to guarantee it). You should utilize a TCP connection for multiple customers for example ->

<property name="javax.persistence.jdbc.url" value="jdbc:h2:tcp://localhost/C:\Database\Data\production;"/>



Additionally, it means you have to start the server in TCP mode. Honesetly, it's pretty easy within the documentation.

Pressure get rid of the process (javaw.exe for Home windows), and make certain that any application that may have began it's shut lower. You possess an active lock.