sqlite jdbc错误sqlite\u IOERR\u锁
我有一个java8程序的可运行jar,它使用sqlite jdbc错误sqlite\u IOERR\u锁,sqlite,sqlitejdbc,Sqlite,Sqlitejdbc,我有一个java8程序的可运行jar,它使用sqlitejdbc3.14.2。它在Windows10和ubuntu上运行良好。i、 我可以在这些平台上查询所有表上的内容。但是,当我在FreeBSD 10.3-releasep4上运行它时,当我在所有表上运行查询时,会出现以下错误 FreeBSD 10.3-release上的建议文件锁定逻辑(磁盘I/O错误)中的[SQLITE\u IOERR\u LOCK]I/O错误 请建议解决方法或解决方案 3.16.1也存在同样的问题,所以我最终发现了问题所在
sqlitejdbc3.14.2
。它在Windows10和ubuntu上运行良好。i、 我可以在这些平台上查询所有表上的内容。但是,当我在FreeBSD 10.3-releasep4上运行它时,当我在所有表上运行查询时,会出现以下错误
FreeBSD 10.3-release上的建议文件锁定逻辑(磁盘I/O错误)中的[SQLITE\u IOERR\u LOCK]I/O
错误
请建议解决方法或解决方案
3.16.1也存在同样的问题,所以我最终发现了问题所在。导致问题的是NFS装载的卷。使用本地文件系统上的DB文件,它工作起来很有魅力。所以我终于找到了问题所在。导致问题的是NFS装载的卷。使用本地文件系统上的DB文件,它的工作方式很有魅力。如果以后有人遇到这个问题,可以先用WAL日志记录模式创建或打开一个DB,然后写一些东西,然后关闭DB并尝试在日志记录关闭的情况下以只读模式再次打开它,从而重现此错误。此单元测试将再现错误:
@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 ) {}
}
如果以后有人遇到这个问题,可以先用日志记录模式创建或打开一个数据库,写入一些内容,然后关闭数据库,并在日志记录关闭的情况下以只读模式再次打开它,从而重现此错误。此单元测试将再现错误:
@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 ) {}
}