/** * Begin a transaction on the database. If not using managed transaction begin a local transaction. */ public void beginTransaction(AbstractSession session) throws DatabaseException { if (usesExternalTransactionController()) { setIsInTransaction(true); return; } session.log(SessionLog.FINER, SessionLog.TRANSACTION, "begin_transaction", (Object[])null, this); try { session.startOperationProfile(SessionProfiler.TRANSACTION); incrementCallCount(session); basicBeginTransaction(session); setIsInTransaction(true); } finally { decrementCallCount(); session.endOperationProfile(SessionProfiler.TRANSACTION); } }
/** * To be called after JTS transaction has been completed (committed or rolled back) */ public void afterJTSTransaction() { if (usesExternalTransactionController()) { setIsInTransaction(false); if ((getDatasourceConnection() != null) && usesExternalConnectionPooling()) { closeConnection(); setDatasourceConnection(null); } } }
/** * PUBLIC: * Reconnect to the database. This can be used if the connection was disconnected or timedout. * This ensures that the security is checked as it is public. * Because the messages can take a long time to build, * pre-check whether messages should be logged. */ public void reestablishConnection(AbstractSession session) throws DatabaseException { if (session.shouldLog(SessionLog.CONFIG, SessionLog.CONNECTION)) {// Avoid printing if no logging required. Object[] args = { getLogin() }; session.log(SessionLog.CONFIG, SessionLog.CONNECTION, "reconnecting", args, this); } reconnect(session); setIsInTransaction(false); session.getEventManager().postConnect(this); }
/** * Disconnect from the datasource. */ public void disconnect(AbstractSession session) throws DatabaseException { session.log(SessionLog.CONFIG, SessionLog.CONNECTION, "disconnect", (Object[])null, this); if (getDatasourceConnection() == null) { return; } session.incrementProfile(SessionProfiler.TlDisconnects); session.startOperationProfile(SessionProfiler.CONNECT); closeDatasourceConnection(); setDatasourceConnection(null); setIsInTransaction(false); session.endOperationProfile(SessionProfiler.CONNECT); }
setIsInTransaction(false); if ((getDatasourceConnection() != null) && usesExternalConnectionPooling()) { closeConnection(); setIsInTransaction(false); } finally { decrementCallCount();
setIsInTransaction(false); if ((getDatasourceConnection() != null) && usesExternalConnectionPooling()) { closeConnection(); setIsInTransaction(false); decrementCallCount(); session.endOperationProfile(SessionProfiler.TRANSACTION);
/** * Connect to the datasource. Through using a CCI ConnectionFactory. * Catch exceptions and re-throw as TopLink exceptions. */ public void connect(Login login, AbstractSession session) throws DatabaseException { session.startOperationProfile(SessionProfiler.CONNECT); session.incrementProfile(SessionProfiler.TlConnects); try { if (session.shouldLog(SessionLog.CONFIG, SessionLog.CONNECTION)) {// Avoid printing if no logging required. session.log(SessionLog.CONFIG, SessionLog.CONNECTION, "connecting", new Object[] { login }, this); } setLogin(login); this.setDatasourcePlatform((DatasourcePlatform)session.getDatasourceLogin().getDatasourcePlatform()); try { connect(login); setIsInTransaction(false); } catch (RuntimeException exception) { session.handleSevere(exception); } session.getEventManager().postConnect(this); incrementCallCount(session); try { buildConnectLog(session); } finally { decrementCallCount(); } } finally { session.endOperationProfile(SessionProfiler.CONNECT); } }