public class PoolableConnection extends DelegatingConnection<Connection> implements PoolableConnectionMXBean
ObjectPool
when closed.TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE| Constructor and Description |
|---|
PoolableConnection(Connection conn,
ObjectPool<PoolableConnection> pool,
ObjectName jmxName) |
PoolableConnection(Connection conn,
ObjectPool<PoolableConnection> pool,
ObjectName jmxObjectName,
Collection<String> disconnectSqlCodes,
boolean fastFailValidation) |
| Modifier and Type | Method and Description |
|---|---|
void |
abort(Executor executor)
Abort my underlying
Connection. |
void |
close()
Returns me to my pool.
|
Collection<String> |
getDisconnectionSqlCodes() |
String |
getToString()
Expose the
DelegatingConnection.toString() method via a bean getter so it can be read as a property via JMX. |
protected void |
handleException(SQLException e) |
boolean |
isClosed()
This method should not be used by a client to determine whether or not a connection should be return to the
connection pool (by calling
close()). |
boolean |
isFastFailValidation() |
protected void |
passivate() |
void |
reallyClose()
Actually close my underlying
Connection. |
void |
validate(String sql,
int timeoutSeconds)
Validates the connection, using the following algorithm:
If
fastFailValidation (constructor argument) is true and this connection has previously
thrown a fatal disconnection exception, a SQLException is thrown. |
activate, checkOpen, clearCachedState, clearWarnings, closeInternal, commit, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStatement, createStatement, createStruct, getAutoCommit, getCacheState, getCatalog, getClientInfo, getClientInfo, getDefaultQueryTimeout, getDelegate, getDelegateInternal, getHoldability, getInnermostDelegate, getInnermostDelegateInternal, getMetaData, getNetworkTimeout, getSchema, getTransactionIsolation, getTypeMap, getWarnings, handleExceptionNoThrow, innermostDelegateEquals, isClosedInternal, isReadOnly, isValid, isWrapperFor, nativeSQL, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCacheState, setCatalog, setClientInfo, setClientInfo, setClosedInternal, setDefaultQueryTimeout, setDelegate, setHoldability, setNetworkTimeout, setReadOnly, setSavepoint, setSavepoint, setSchema, setTransactionIsolation, setTypeMap, toString, unwrapaddTrace, clearTrace, getLastUsed, getTrace, removeThisTrace, removeTrace, setLastUsed, setLastUsedclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclearCachedState, clearWarnings, getAutoCommit, getCacheState, getCatalog, getHoldability, getSchema, getTransactionIsolation, isReadOnly, setAutoCommit, setCacheState, setCatalog, setHoldability, setReadOnly, setSchema, setTransactionIsolationpublic PoolableConnection(Connection conn, ObjectPool<PoolableConnection> pool, ObjectName jmxObjectName, Collection<String> disconnectSqlCodes, boolean fastFailValidation)
conn - my underlying connectionpool - the pool to which I should return when closedjmxObjectName - JMX namedisconnectSqlCodes - SQL_STATE codes considered fatal disconnection errorsfastFailValidation - true means fatal disconnection errors cause subsequent validations to fail immediately (no attempt to
run query or isValid)public PoolableConnection(Connection conn, ObjectPool<PoolableConnection> pool, ObjectName jmxName)
conn - my underlying connectionpool - the pool to which I should return when closedjmxName - JMX nameprotected void passivate()
throws SQLException
passivate in class DelegatingConnection<Connection>SQLExceptionpublic boolean isClosed()
throws SQLException
This method should not be used by a client to determine whether or not a connection should be return to the
connection pool (by calling close()). Clients should always attempt to return a connection to the pool
once it is no longer required.
isClosed in interface ConnectionisClosed in interface PoolableConnectionMXBeanisClosed in class DelegatingConnection<Connection>SQLExceptionpublic void close()
throws SQLException
close in interface AutoCloseableclose in interface Connectionclose in interface PoolableConnectionMXBeanclose in class DelegatingConnection<Connection>SQLExceptionpublic void reallyClose()
throws SQLException
Connection.reallyClose in interface PoolableConnectionMXBeanSQLExceptionpublic void abort(Executor executor) throws SQLException
Connection.abort in interface Connectionabort in class DelegatingConnection<Connection>SQLExceptionpublic String getToString()
DelegatingConnection.toString() method via a bean getter so it can be read as a property via JMX.getToString in interface PoolableConnectionMXBeanpublic void validate(String sql, int timeoutSeconds) throws SQLException
fastFailValidation (constructor argument) is true and this connection has previously
thrown a fatal disconnection exception, a SQLException is thrown.sql is null, the driver's #isValid(timeout) is called. If it
returns false, SQLException is thrown; otherwise, this method returns successfully.sql is not null, it is executed as a query and if the resulting ResultSet contains at
least one row, this method returns successfully. If not, SQLException is thrown.sql - The validation SQL query.timeoutSeconds - The validation timeout in seconds.SQLException - Thrown when validation fails or an SQLException occurs during validationprotected void handleException(SQLException e) throws SQLException
handleException in class DelegatingConnection<Connection>SQLExceptionpublic Collection<String> getDisconnectionSqlCodes()
public boolean isFastFailValidation()
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.