我在使用 SqlJet Transactions 时尝试访问我的数据库,但我一直收到此错误
org.tmatesoft.sqljet.core.SqlJetException: MISUSE: error code is MISUSE
这是我的代码:
SqlJetDb db = null;
try {
File dbFile = new File(Configuration.DATABASE_NAME);
db = SqlJetDb.open(dbFile, true);
db.getOptions().setAutovacuum(true);
db.beginTransaction(SqlJetTransactionMode.READ_ONLY);
ISqlJetTable table = db.getTable("customers");
ISqlJetCursor cursor = table.order(table.getPrimaryKeyIndexName());
if (!cursor.eof()) {
do {
getInitData(cursor);
} while (cursor.next());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
db.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
有人知道这个问题有什么问题吗?由于这个列表,实际库的使用是不正确的,但我已经检查过了,对我来说没有任何问题。 http://grepcode.com/file/repo1.maven.org/maven2/org.tmatesoft.sqljet/sqljet/1.0.2/org/tmatesoft/sqljet/core/SqlJetErrorCode.java#SqlJetErrorCode
谢谢!
最佳答案
发生这种情况是因为您试图打开一个已经被另一个进程打开的数据库。 它发生在我身上是因为数据库是由 Firefox SQLite Manager 打开的,但基本上它可能由访问您的数据库的任何其他线程或进程发生。
关于java - SqlJet 事务误用错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14834565/