3

I'm trying to access my database while using SqlJet Transactions, but I get this error all the time

org.tmatesoft.sqljet.core.SqlJetException: MISUSE: error code is MISUSE

Here is my code:

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();
                }
            }

Does anybody know what's wrong with the issue? Due to this list, the actuall library usage was improper, but I've checked it out and there wasn't anything wrong to me. http://grepcode.com/file/repo1.maven.org/maven2/org.tmatesoft.sqljet/sqljet/1.0.2/org/tmatesoft/sqljet/core/SqlJetErrorCode.java#SqlJetErrorCode

Thanks!

1 Answers1

0

It happens because you are trying to open a DB that is already opened by another process . it happened to me because the db was opened by Firefox SQLite Manager, but basically it could happen by any other thread or process accessing your DB .

Mistriel
  • 459
  • 4
  • 9