public static void ensureDomainRoot() { PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker(); try { broker.beginTransaction();
/** * 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!"); } }
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; }
txObject.setPreviousIsolationLevel(previousIsolationLevel); pb.beginTransaction();
txObject.setPreviousIsolationLevel(previousIsolationLevel); pb.beginTransaction();
txObject.setPreviousIsolationLevel(previousIsolationLevel); pb.beginTransaction();