1

I have a runnable jar for a java8 program which uses sqlite-jdbc 3.14.2. It works fine on windows 10 and ubuntu. i.e. i can query stuff on these platforms on all the tables. However, when i run it on FreeBSD 10.3-releasep4, it gives me the following error when i run queries on all the tables.

[SQLITE_IOERR_LOCK] I/O error in the advisory file locking logic (disk I/O error) on FreeBSD 10.3-release

Please advise a workaround or solution.

Same issue exists with 3.16.1

muzammil
  • 11
  • 2

2 Answers2

0

So I finally found out what was wrong. It was an NFS mounted volume that was causing the problem. With DB file on local file system, it works like a charm.

muzammil
  • 11
  • 2
0

If anyone is coming to this question at later time, this error can be reproduced by first creating or opening a DB with WAL journalling mode, writing something, then closing the DB and trying to open it again in read-only mode with journalling off. This unit test will reproduce the error:

@Test
public void mixJournalingModesFailureTest()
{
    File tempDb = File.createTempFile("tempdbtest", ".db");
    tempDb.deleteOnExit();

    // Open a temp DB in RW mode with WAL journalling
    String url = "jdbc:sqlite:" + tempDb.getAbsolutePath();
    SQLiteConfig config = new SQLiteConfig();

    // Ser read-write with WAL journalling
    config.setJournalMode( SQLiteConfig.JournalMode.WAL );
    config.setReadOnly( false );

    Properties props = config.toProperties();
    Connection conn = DriverManager.getConnection( url, props );

    // Write something
    try ( Statement statement = conn.createStatement() )
    {
        statement.execute( "CREATE TABLE test (words text)" );
    }

    // Close the DB
    conn.close();

    // Open the DB again but with journalling off and in read-only mode
    config.setJournalMode( SQLiteConfig.JournalMode.OFF );
    config.setReadOnly( true );

    props = config.toProperties();

    try
    {
        // This will throw the SQLITE_IOERR_LOCK advisory lock exception
        DriverManager.getConnection( url, props );
        fail( "Should throw advisory lock exception" );
    }
    catch ( SQLException ignore ) {}
}
Drakes
  • 23,254
  • 3
  • 51
  • 94