broker.commitTransaction(); stm.close(); conn.close();
/** * 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!"); } }
broker.commitTransaction(); } catch (Exception e) {
pb.commitTransaction(); } catch (Throwable t) { t.printStackTrace();
public static int initializeTransactionSystem() { // find the last committed transaction PersistenceBroker broker = null; try { broker = PersistenceBrokerFactory.defaultPersistenceBroker(); broker.beginTransaction(); Connection conn = broker.serviceConnectionManager().getConnection(); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT MAX(TX_NUMBER) FROM FF$TX_CHANGE_LOGS"); int maxTx = (rs.next() ? rs.getInt(1) : -1); broker.commitTransaction(); broker.close(); broker = null; stmt.close(); rs.close(); new CleanThread(maxTx).start(); new StatisticsThread().start(); return maxTx; } catch (Exception e) { throw new Error("Couldn't initialize the transaction system"); } finally { if (broker != null) { broker.close(); } } }
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; }
protected void doCommit(DefaultTransactionStatus status) { PersistenceBrokerTransactionObject txObject = (PersistenceBrokerTransactionObject) status.getTransaction(); if (status.isDebug()) { logger.debug("Committing OJB transaction on PersistenceBroker [" + txObject.getPersistenceBrokerHolder().getPersistenceBroker() + "]"); } try { txObject.getPersistenceBrokerHolder().getPersistenceBroker().commitTransaction(); } catch (TransactionAbortedException ex) { // assumably from commit call to underlying JDBC connection throw new TransactionSystemException("Could not commit OJB transaction", ex); } }
protected void doCommit(DefaultTransactionStatus status) { PersistenceBrokerTransactionObject txObject = (PersistenceBrokerTransactionObject) status.getTransaction(); if (status.isDebug()) { logger.debug("Committing OJB transaction on PersistenceBroker [" + txObject.getPersistenceBrokerHolder().getPersistenceBroker() + "]"); } try { txObject.getPersistenceBrokerHolder().getPersistenceBroker().commitTransaction(); } catch (TransactionAbortedException ex) { // assumably from commit call to underlying JDBC connection throw new TransactionSystemException("Could not commit OJB transaction", ex); } }
protected void doCommit(DefaultTransactionStatus status) { PersistenceBrokerTransactionObject txObject = (PersistenceBrokerTransactionObject) status.getTransaction(); if (status.isDebug()) { logger.debug("Committing OJB transaction on PersistenceBroker [" + txObject.getPersistenceBrokerHolder().getPersistenceBroker() + "]"); } try { txObject.getPersistenceBrokerHolder().getPersistenceBroker().commitTransaction(); } catch (TransactionAbortedException ex) { // assumably from commit call to underlying JDBC connection throw new TransactionSystemException("Could not commit OJB transaction", ex); } }