/** * Aborts transaction on a non-null broker in transaction. * * @throws PersistenceException if a low-level exception is caught * @throws IllegalStateException if a transaction is not already in progress or if broker not initialized */ protected void rollbackTransaction() throws PersistenceException { if (broker != null) { try { if (broker.isInTransaction()) { broker.abortTransaction(); } else { throw new IllegalStateException("Called to rollback a transaction when has not been started yet."); } } catch (PersistenceBrokerException e) { throw new PersistenceException("Could not rollback transaction", e); } } else { throw new IllegalStateException("Called to rollback transaction when broker not properly initialized!"); } }
@Override protected void suspendTx() { // close the broker to release the db connection on suspension if (broker != null) { if (broker.isInTransaction()) { broker.abortTransaction(); } broker.close(); broker = null; } super.suspendTx(); }
/** * Begins a transaction on a non-null broker. * * @throws PersistenceException if a low-level exception is caught * @throws IllegalStateException if a transaction is already in progress or if broker not initialized */ protected void beginTransaction() throws PersistenceException, IllegalStateException { //begin transction if (broker != null) { try { if (!broker.isInTransaction()) { broker.beginTransaction(); } else { throw new IllegalStateException("Called to begin transaction when one is already in progress"); } } catch (TransactionInProgressException e) { throw new PersistenceException("Could not start transaction", e); } catch (TransactionAbortedException e) { throw new PersistenceException("Could not start transaction", e); } } else { throw new IllegalStateException("Called to begin transaction when broker not properly initialized!"); } }
/** * Commits a transaction on a non-null broker. If broker is null, does nothing. * * @throws PersistenceException if a low-level exception is caught * @throws IllegalStateException if a transaction is not already in progress or if broker not initialized */ protected void commitTransaction() throws PersistenceException { //commit transaction if (broker != null) { try { if (broker.isInTransaction()) { broker.commitTransaction(); } else { throw new IllegalStateException("Called to commit a transaction when has not been started yet."); } } catch (TransactionNotInProgressException e) { throw new PersistenceException("Could not commit transaction", e); } catch (TransactionAbortedException e) { throw new PersistenceException("Could not commit transaction", e); } } else { throw new IllegalStateException("Called to commit transaction when broker not properly initialized!"); } }
@Override protected void finish() { super.finish(); if (broker != null) { if (broker.isInTransaction()) { broker.abortTransaction(); } broker.close(); broker = null; } dbChanges = null; }
if ((broker != null) && (broker.isInTransaction())) { broker.abortTransaction(); if (broker.isInTransaction()) { broker.abortTransaction();
if (broker.isInTransaction()) { broker.abortTransaction();
t.printStackTrace(); logger.error("Couldn't update database in the clean thread because of a Throwable."); if ((broker != null) && (broker.isInTransaction())) { broker.abortTransaction(); if (broker.isInTransaction()) { broker.abortTransaction();
if (!pb.isInTransaction()) { pb.beginTransaction();
if (broker.isInTransaction()) { broker.abortTransaction();
private boolean initializeServerRecord() { PersistenceBroker broker = null; try { broker = PersistenceBrokerFactory.defaultPersistenceBroker(); broker.beginTransaction(); Connection conn = broker.serviceConnectionManager().getConnection(); Statement stmt = conn.createStatement(); // delete previous record for this server and insert a new one stmt.executeUpdate("DELETE FROM FF$LAST_TX_PROCESSED WHERE SERVER = '" + server + "' or LAST_UPDATE < (NOW() - interval 3600 second)"); stmt.executeUpdate("INSERT INTO FF$LAST_TX_PROCESSED VALUES ('" + server + "'," + lastTxNumber + ",null)"); broker.commitTransaction(); return true; } catch (Exception e) { e.printStackTrace(); logger.error("Couldn't initialize the clean thread"); //throw new Error("Couldn't initialize the clean thread"); if (broker != null) { broker.abortTransaction(); } } finally { if (broker != null) { if (broker.isInTransaction()) { broker.abortTransaction(); } broker.close(); } } return false; }
} finally { if (broker != null) { if (broker.isInTransaction()) { broker.abortTransaction();