0

I'm using Maven on NetBeans to import H2 Database to my project and the following code to init. a simple embedded database:

//...
Class.forName("org.h2.Driver");
//...
connection = DriverManager.getConnection("jdbc:h2:~/MCUsers");
//...

When I run the code on my Windows machine (where I do the programming), it works fine and I can create tables and rows. But when I run the same JAR file on my Linux machine, I get the following error:

Error Code:90020 Message:Database may be already in use: null. Possible solutions: close all other connection(s); use the server mode [90020-194] Cause:java.lang.IllegalStateException: The file is locked: nio:/root/MCUsers.mv.db [1.4.194/7]

  • The same JAR runs on my Windows machine with no problems.
  • There are no other Java programs running on my Linux machine.
  • I already tried to reboot the system - didn't work.
  • Only The files MCUsers.mv.db & MCUsers.trace.db are created in the root directory after this error occurs.
  • My Linux machine uses JRE1.8.0_112 to execute the JAR file.

Edit: Adding "FILE_LOCK=NO;" also didn't work.

OmriSoudry
  • 361
  • 3
  • 13
  • Coukd be file permission issue? Also, are you sure ~ is supported in the path? It's a shell thing, normally not expanded by many programs, (not sure of JDBC or H2). – hyde Apr 09 '17 at 11:30
  • Are you possibly opening the db more than once? – Lev Kuznetsov Apr 09 '17 at 11:30
  • LevKuznetsov Yes, the only code in main is the one posted. @hyde I'm running the JAR file with the root user, and the ~ is actually in the H2 getting started guides. – OmriSoudry Apr 09 '17 at 11:41
  • Running as root might also be the issue. There are programs which refuse to run as root due to security concerns. Probably not issue here, but not impossible. – hyde Apr 09 '17 at 13:23

0 Answers0