title: H2 database error: Database may be already in use: "Locked by another process"
body: <p>I am trying to use the H2 database from a Java application. </p>
  
  <p>I created the database and its tables through the H2 Console and then I try to connect from Java using </p>
  
  <pre><code>Connection con = DriverManager.getConnection("jdbc:h2:~/dbname", "username", "password");
  </code></pre>
  
  <p>However I receive the following error:</p>
  
  <blockquote>
    <p>Exception in thread "main" org.h2.jdbc.JdbcSQLException: Database may be already in use: "Locked by another process". Possible solutions: close all other connection(s); use the server mode [90020-161]</p>
  </blockquote>
  
  <p>I  tried to delete the <code>dbname.lock.db</code> file but it is automatically re-created.</p>
  
  <p>How can I unlock the database to use it from my Java program?</p>