SqlJet Transaction Misuse Error

I am trying to access my database while using SqlJet transactions but I am getting 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 anyone know what happened to the problem? Because of this list, using the executable library was wrong, but I checked it out and there was nothing wrong with me. http://grepcode.com/file/repo1.maven.org/maven2/org.tmatesoft.sqljet/sqljet/1.0.2/org/tmatesoft/sqljet/core/SqlJetErrorCode.java#SqlJetErrorCode

Thank!

+3


source to share


1 answer


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



0


source







All Articles