private <T> T execute(Query<T> query, DB db) throws SqlJetException { Pool<SqlJetDb, SqlJetException> pool = this.pools.get(db); Lock lock = this.locks.get(db).readLock(); SqlJetDb database = pool.take(); lock.lock(); try { database.beginTransaction(SqlJetTransactionMode.READ_ONLY); try { return query.execute(database); } finally { database.commit(); } } finally { lock.unlock(); pool.release(database); } }
private void createStructure(SqlJetDb db) throws SqlJetException { db.beginTransaction(SqlJetTransactionMode.WRITE); try { db.createTable("CREATE TABLE states (full_name TEXT NOT NULL PRIMARY KEY, version TEXT NULL)"); db.createIndex("CREATE INDEX full_name_index ON states(full_name)"); } finally { db.commit(); } }
database.commit();
public void statementCompleted(SqlJetDb db, SqlJetException error) throws SqlJetException { if (error == null) { this.db.getDb().getTemporaryDatabase().commit(); } else { this.db.getDb().getTemporaryDatabase().rollback(); } }
public void statementCompleted(SqlJetDb db, SqlJetException error) throws SqlJetException { if (error == null) { this.db.getDb().getTemporaryDatabase().commit(); } else { this.db.getDb().getTemporaryDatabase().rollback(); } }
public void statementCompleted(SqlJetDb db, SqlJetException error) throws SqlJetException { if (error == null) { this.db.getDb().getTemporaryDatabase().commit(); } else { this.db.getDb().getTemporaryDatabase().rollback(); } }
public void statementCompleted(SqlJetDb db, SqlJetException error) throws SqlJetException { if (error == null) { this.db.getDb().getTemporaryDatabase().commit(); } else { this.db.getDb().getTemporaryDatabase().rollback(); } }
@Override public void insert(State state) { try { db.beginTransaction(SqlJetTransactionMode.WRITE); try { ISqlJetTable table = db.getTable(StateTable.TABLE_NAME); table.insert(getData(state)); } finally { db.commit(); } } catch (Throwable e) { logger.error("unable to insert: " + state, e); } }
public void commit() throws SVNException { if (openCount > 0) { openCount--; if (isLogTransactions()) { logCall("Commit transaction request (" + openCount + ")", 5); } if (openCount == 0) { try { db.commit(); if (isLogTransactions()) { SVNDebugLog.getDefaultLog().logFine(SVNLogType.DEFAULT, "transaction committed"); } } catch (SqlJetException e) { createSqlJetError(e); } } } else { SVNErrorManager.assertionFailure(openCount > 0, "no opened transactions", SVNLogType.WC); } }
@Override public void delete(String fullname) { try { db.beginTransaction(SqlJetTransactionMode.WRITE); try { ISqlJetTable table = db.getTable(StateTable.TABLE_NAME); ISqlJetCursor cursor = table.lookup(StateTable.NDX_FULL_NAME, fullname); while (!cursor.eof()) { cursor.delete(); } cursor.close(); } finally { db.commit(); } } catch (Throwable e) { logger.error("unable to delete: " + fullname, e); } }
private static Map<SvnChecksum, Integer> calculateCorrectChecksumRefcounts(SVNWCDbRoot root) throws SVNException { Map<SvnChecksum, Integer> checksumToRefCount = new HashMap<SvnChecksum, Integer>(); final SqlJetDb db = root.getSDb().getDb(); try { final ISqlJetTable nodesTable = db.getTable(SVNWCDbSchema.NODES.name()); db.beginTransaction(SqlJetTransactionMode.READ_ONLY); final ISqlJetCursor cursor = nodesTable.open(); for (; !cursor.eof(); cursor.next()) { String sha1ChecksumString = cursor.getString(SVNWCDbSchema.NODES__Fields.checksum.name()); if (sha1ChecksumString == null) { continue; } SvnChecksum sha1Checksum = SvnChecksum.fromString(sha1ChecksumString); Integer refCount = checksumToRefCount.get(sha1Checksum); int incrementedRefCount = refCount == null ? 1 : refCount + 1; checksumToRefCount.put(sha1Checksum, incrementedRefCount); } cursor.close(); } catch (SqlJetException e) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.WC_DB_ERROR, e); SVNErrorManager.error(errorMessage, e, SVNLogType.WC); } finally { try { db.commit(); } catch (SqlJetException ignore) { } } return checksumToRefCount; }
@Override public State get(String fullname) { try { db.beginTransaction(SqlJetTransactionMode.WRITE); try { ISqlJetTable table = db.getTable(StateTable.TABLE_NAME); ISqlJetCursor cursor = table.lookup(StateTable.NDX_FULL_NAME, fullname); if (!cursor.eof()) { State state = read(cursor); cursor.close(); return state; } } finally { db.commit(); } } catch (Throwable e) { logger.error("unable to get " + fullname, e); } return null; }
@Override public void update(State state) { try { db.beginTransaction(SqlJetTransactionMode.WRITE); try { ISqlJetTable table = db.getTable(StateTable.TABLE_NAME); ISqlJetCursor cursor = table.lookup(StateTable.NDX_FULL_NAME, state.fullname); while (!cursor.eof()) { cursor.update(getData(state)); cursor.next(); } cursor.close(); } finally { db.commit(); } } catch (Throwable e) { logger.error("unable to update: " + state, e); } }
sqljetDb.commit(); } catch (SqlJetException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.SQLITE_ERROR, e);
private static Map<SvnChecksum, Integer> loadChecksumsRefcountsFromTable(SVNWCDbRoot root) throws SVNException { Map<SvnChecksum, Integer> checksumToRefCount = new HashMap<SvnChecksum, Integer>(); final SqlJetDb db = root.getSDb().getDb(); try { final ISqlJetTable pristineTable = db.getTable(SVNWCDbSchema.PRISTINE.name()); db.beginTransaction(SqlJetTransactionMode.READ_ONLY); final ISqlJetCursor cursor = pristineTable.open(); for (; !cursor.eof(); cursor.next()) { String sha1ChecksumString = cursor.getString(PRISTINE__Fields.checksum.name()); if (sha1ChecksumString == null) { continue; } SvnChecksum sha1Checksum = SvnChecksum.fromString(sha1ChecksumString); long refcount = cursor.getInteger(PRISTINE__Fields.refcount.name()); checksumToRefCount.put(sha1Checksum, (int)refcount); } cursor.close(); } catch (SqlJetException e) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.WC_DB_ERROR, e); SVNErrorManager.error(errorMessage, e, SVNLogType.WC); } finally { try { db.commit(); } catch (SqlJetException ignore) { } } return checksumToRefCount; }
sqljetDb.commit(); } catch (SqlJetException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.SQLITE_ERROR, e);
sqljetDb.commit(); } catch (SqlJetException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.SQLITE_ERROR, e);