sqlite jdbc 错误 SQLITE_IOERR_LOCK
sqlite jdbc error SQLITE_IOERR_LOCK
我有一个 运行 可用于 java8 程序的 jar,它使用 sqlite-jdbc 3.14.2
。它在 windows 10 和 ubuntu 上运行良好。即我可以在所有表上查询这些平台上的内容。但是,当我 运行 它在 FreeBSD 10.3-releasep4 上时,当我 运行 查询所有表时,它会给我以下错误。
[SQLITE_IOERR_LOCK] I/O
FreeBSD 10.3-release
上的建议文件锁定逻辑错误(磁盘 I/O 错误)
请告知解决方法或解决方案。
3.16.1 存在同样的问题
所以我终于发现了问题所在。这是导致问题的 NFS 安装卷。在本地文件系统上使用 DB 文件,它就像一个魅力。
如果以后有人提出这个问题,可以通过首先使用 WAL 日志模式创建或打开数据库,写一些东西,然后关闭数据库来重现这个错误并尝试以只读模式再次打开它并记录 off。此单元测试将重现错误:
@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 ) {}
}
我有一个 运行 可用于 java8 程序的 jar,它使用 sqlite-jdbc 3.14.2
。它在 windows 10 和 ubuntu 上运行良好。即我可以在所有表上查询这些平台上的内容。但是,当我 运行 它在 FreeBSD 10.3-releasep4 上时,当我 运行 查询所有表时,它会给我以下错误。
[SQLITE_IOERR_LOCK] I/O
FreeBSD 10.3-release
请告知解决方法或解决方案。
3.16.1 存在同样的问题
所以我终于发现了问题所在。这是导致问题的 NFS 安装卷。在本地文件系统上使用 DB 文件,它就像一个魅力。
如果以后有人提出这个问题,可以通过首先使用 WAL 日志模式创建或打开数据库,写一些东西,然后关闭数据库来重现这个错误并尝试以只读模式再次打开它并记录 off。此单元测试将重现错误:
@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 ) {}
}