Issue #8 resolved

SQLITE_NOTADB : file is encrypted when setting sqlite.purejava to true

Anonymous created an issue

==== What steps will reproduce the problem? ==== Create a Java class "Sqlite_notadb" with the following content and place a WAL-enabled SQLite database 'wal-enabled_database.db' into the directory where the class resides. Then run the class. {{{ import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement;

public class Sqlite_notadb { public static void main(String[] args) throws ClassNotFoundException, SQLException { System.setProperty("sqlite.purejava", "true"); Class.forName("org.sqlite.JDBC"); Connection connection = DriverManager.getConnection("jdbc:sqlite:wal-enabled_database.db"); Statement statement = connection.createStatement(); ResultSet rs = statement.executeQuery("select nothing from notexistingtable where first is not null order by first"); } } }}} ==== What is the expected output? What do you see instead? ==== Expected: No error. Instead: {{{java.sql.SQLException: [SQLITE_NOTADB]  File opened that is not a database file (file is encrypted or is not a database)}}}

==== What version of the product are you using? On what operating system? ==== sqlite-jdbc-3.7.2.jar or sqlite-jdbc-3.7.6.3-20110609.081603-3.jar Windows XP SP3 JDK 1.7.0_04, Eclipse set to compliance 'J2SE-1.5'

==== Please provide any additional information below. ==== The SQL-query can be arbitrary but must be valid. The purejava driver is being used.

Supposed reason of error: "Beginning with version 3.7.0, a new 'Write-Ahead Log' option (hereafter referred to as "WAL") is available." [...] "Thus, if an older version of SQLite attempts to connect to an SQLite database that is operating in WAL mode, it will report an error along the lines of 'file is encrypted or is not a database'." Source: http://www.sqlite.org/wal.html

Comments (5)

  1. Grace Batumbya

    WAL is now supported. To enable it, you need to pass it as a property to the DriverManager as you request for a connection.

    You will need to change

    Connection connection = DriverManager.getConnection("jdbc:sqlite:wal-enabled_database.db");
    

    to

    Properties config = new Properties();
    config.put("journal_mode", "WAL");
    Connection con = DriverManager.getConnection("jdbc:sqlite:wal-enabled_database.db", config);
    
  2. Guy Erlich

    I tried the suggestion above, and now I get another error: java.sql.BatchUpdateException: batch entry 0: query returns results at org.sqlite.Stmt.executeBatch(Stmt.java:226)

    Any suggestions?

  3. Log in to comment