title: Java - JDBC Driver SQLite 3.7.2 - Unable to open database test.db: file is encrypted or is not a database
body: <p>I'm writing some data to a database file using the SQLite JDBC driver 3.7.2 from within java . When I try it to open the database file on the command line, I get an error message saying:</p>
  
  <p>"Unable to open database test.db: file is encrypted or is not a database"</p>
  
  <p>I made a minimal example that results in this behavior:</p>
  
  <pre><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.PreparedStatement;
  import java.sql.SQLException;
  import java.sql.Statement;
  
  public class PlaygroundSQLite {
      public static void insertIntoDB(String dbFilename, String tablename){
          try {
              Class.forName("org.sqlite.JDBC");
              Connection conn = DriverManager.getConnection("jdbc:sqlite:"+dbFilename);
              PreparedStatement prep = conn.prepareStatement("insert into " + tablename + "( id, text) values (?, ?);");
  
              prep.setString(1, "1FD22A38");
              prep.setString(2, "This is a simple test");
  
              prep.addBatch();
  
              conn.setAutoCommit(false);
              prep.executeBatch();
              conn.setAutoCommit(true);
  
              conn.close();
  
          } catch (ClassNotFoundException e) {
              e.printStackTrace();
          } catch (SQLException e) {
              e.printStackTrace();
          }
      }
  
      public static void createDB(String dbFilename, String tablename){
          try {
              Class.forName("org.sqlite.JDBC");
              Connection conn = DriverManager.getConnection("jdbc:sqlite:" + dbFilename);
              Statement stat = conn.createStatement();
              stat.executeUpdate("drop table if exists test;");
              stat.executeUpdate("create table " + tablename + " (key INTEGER PRIMARY KEY, id TEXT , text TEXT);");
              conn.close();
              stat.close();
          } catch (ClassNotFoundException e) {
              e.printStackTrace();
          } catch (SQLException e) {
              e.printStackTrace();
          }
      }
  
      public static void main(String[] args) {
          String dbFilename = "test.db";
          String tablename = "test";
  
          PlaygroundSQLite.createDB(dbFilename, tablename);
          PlaygroundSQLite.insertIntoDB(dbFilename, tablename);
      }
  }
  </code></pre>