1

我有一个用于 java8 程序的可运行 jar,它使用sqlite-jdbc 3.14.2. 它在 Windows 10 和 ubuntu 上运行良好。即我可以在所有表​​上查询这些平台上的东西。但是,当我在 FreeBSD 10.3-releasep4 上运行它时,当我对所有表运行查询时,它给了我以下错误。

[SQLITE_IOERR_LOCK] I/OFreeBSD 10.3-release 上的咨询文件锁定逻辑错误(磁盘 I/O 错误)

请提供解决方法或解决方案。

3.16.1 也存在同样的问题

4

2 回答 2

0

所以我终于发现出了什么问题。这是导致问题的 NFS 安装卷。使用本地文件系统上的数据库文件,它就像一个魅力。

于 2017-01-26T06:14:50.197 回答
0

如果稍后有人提出这个问题,则可以通过首先创建或打开具有WAL日志模式的数据库,写入一些内容,然后关闭数据库并尝试在日志模式关闭的只读模式下再次打开它来重现此错误。此单元测试将重现错误:

@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 ) {}
}
于 2018-10-03T04:34:26.980 回答