我试图在使用SqlJet事务的同时访问我的数据库,但是我总是收到这个错误
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
谢谢!
发布于 2014-04-20 05:17:57
这是因为您正在尝试打开一个已被另一个进程打开的数据库。这发生在我身上,因为数据库是由火狐SQLite管理器打开的,但基本上它可以由任何其他线程或进程访问你的数据库。
https://stackoverflow.com/questions/14834565
复制相似问题