title: Why am I getting SQLException: database is locked on my JDBC SQLite database?
body: <p>I have a single-threaded application that uses 3 SQLite databases in 3 different files on the local file system.</p>
  
  <p>I have created a <code>DbAdapter</code> helper class that opens the connection to the SQLite database file. In this class I have an <code>open</code> method that creates the connection, and a <code>close</code> method that releases everything.</p>
  
  <p>The 3 databases are accessed from a class that derives <code>DbAdapter</code>.</p>
  
  <p>In my program every database access look like this:</p>
  
  <pre><code>MyDbAdapter DB = new MyDBAdapter();
  int stuff = DB.getStuff(); // queries the database
  DB.close();
  // now do something with `stuff`
  </code></pre>
  
  <p>I have logged to <code>stdout</code> all calls to <code>DbAdapter.open</code> and <code>DbAdapter.close</code>. Everytime there's an <code>open()</code>, a <code>close()</code> follows close by.<br>
  I also take the care to close all my <code>Statement</code>s (which will cause the associated <code>ResultSet</code>s to be closed aswell).</p>
  
  <p>So I guess that my database accesses are clean because I'm trying to get them as short as possible, and I release all the resources as soon as I no longer need them.</p>
  
  <p>Yet, I'm still getting a <code>java.sql.SQLException: database is locked</code>.</p>
  
  <p>Is there anything that I'm not doing properly? I know I haven't shown any code, but I'd have to post a LOT of code and it won't be relevant. I'm just asking if I'm using the best practises here, because I think I do and I'm still getting exceptions.</p>
  
  <p>This is with Java 1.6, Xerial.org's sqlite-jdbc-3.7.2 driver, on Mac OS 10.6 x64</p>