/** * Attempt to save some of the cost associated with getting a fresh connection. * Assume the DatabaseDriver has been cached, if appropriate. * Note: Connections that are participating in transactions will not be refreshd.^M * Added for bug 3046465 to ensure the statement cache is cleared */ protected void reconnect(AbstractSession session) { clearStatementCache(session); super.reconnect(session); }
/** * 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); }
/** * Used for load balancing and external pooling. */ public synchronized void incrementCallCount(AbstractSession session) { setCallCount(getCallCount() + 1); if (getCallCount() == 1) { // If the login is null, then this accessor has never been connected. if (getLogin() == null) { throw DatabaseException.databaseAccessorNotConnected(); } // If the connection is no longer connected, it may have timed out. if (getDatasourceConnection() != null) { if (!isConnected()) { if (isInTransaction()) { throw DatabaseException.databaseAccessorNotConnected(); } else { reconnect(session); } } } else { // If ExternalConnectionPooling is used, the connection can be re-established. if (usesExternalConnectionPooling()) { reconnect(session); } else { throw DatabaseException.databaseAccessorNotConnected(); } } } }