java.sql.Connection object
| Modifier and Type | Field and Description |
|---|---|
| private String | abandonTrace
When we track abandon traces, this string holds the thread dump |
| private HashMap | |
| private volatile Connection | connection
The underlying database connection |
| private static final AtomicLong | |
| private volatile long | |
| private volatile boolean | discarded
Set to true if this connection has been discarded by the pool |
| private Driver | |
| private volatile JdbcInterceptor | handler
Weak reference to cache the list of interceptors for this connection so that we don't create a new list of interceptors each time we borrow the connection |
| private volatile long | lastConnected
The Timestamp when the last time the connect() method was called successfully |
| private volatile long | lastValidated
timestamp to keep track of validation intervals |
| private final ReentrantReadWriteLock | lock
Lock for this connection only |
| private static final Log | log
Logger |
| private ObjectName | |
| protected ConnectionPool | parent
The parent |
| protected PoolConfiguration | poolProperties
The properties for the connection pool |
| public static final String | |
| public static final String | |
| private AtomicBoolean | |
| private volatile boolean | |
| private volatile long | timestamp
Timestamp the connection was last 'touched' by the pool |
| public static final int | VALIDATE_BORROW
Validate when connection is borrowed flag |
| public static final int | VALIDATE_IDLE
Validate when connection is idle flag |
| public static final int | VALIDATE_INIT
Validate when connection is initialized flag |
| public static final int | VALIDATE_RETURN
Validate when connection is returned flag |
| protected volatile XAConnection | xaConnection
If using a XAConnection underneath. |
| Access | Constructor and Description |
|---|---|
| public | PooledConnection(PoolConfiguration
- pool properties prop, ConnectionPool - the parent connection pool parent)Constructor |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: trueif the pool does not need to reconnectThe user name username, String The password password)
Deprecated
use
shouldForceReconnect(String, String)
method kept since it was public, to avoid changing interface.
|
| public void | |
| public void | |
| protected void | |
| protected void | |
| public void | |
| private void | disconnect(boolean
if set to true, a call to finalize)ConnectionPool#finalize(PooledConnection) is called.Disconnects the connection. |
| private boolean | doValidate(int
The validation action action)Returns |
| public long | |
| public HashMap | |
| public boolean | |
| public String | |
| public Connection | Returns: the underlying JDBC connection as it was returned from the JDBC driverReturns the underlying connection |
| public long | |
| public JdbcInterceptor | Returns: the first interceptor for this connectionReturns the first handler in the interceptor chain |
| public int | |
| public long | Returns: the timestamp when this connection was created as defined bySystem#currentTimeMillis()Implements org. Returns the timestamp of when the connection was last connected to the database. |
| public long | Returns: the timestamp of the last successful validation query execution as defined bySystem#currentTimeMillis()Implements org. Returns the timestamp of the last successful validation query execution. |
| public ObjectName | |
| public PoolConfiguration | Returns: the configuration for this connection and poolReturns the configuration for this connection and pool |
| public long | |
| public String | |
| public String | Returns: the stack trace or null of no trace was setReturns the stack trace from when this connection was borrowed. |
| public long | Returns: the timestamp of the last pool action as defined bySystem#currentTimeMillis()Implements org. Return the timestamps of last pool action. |
| public int | |
| public XAConnection | Returns: the underlying XA connection as it was returned from the DatasourceReturns the underlying XA connection |
| public boolean | |
| public boolean | Returns: the discarded flag. If the value is true, eitherdisconnect(boolean) has been called or it will be called when the connection is returned to the pool.Implements org. Returns the discarded flag. |
| public boolean | Returns: true if connect() was called successfully and disconnect has not yet been calledImplements org.
|
| public boolean | Returns: Returns true if the connection has been connected more thanPoolConfiguration#getMaxAge() milliseconds. false otherwise.Implements org. Returns true if the connection has been connected more than
|
| public boolean | |
| public boolean | Returns: true if the methodrelease() has been calledImplements org. Returns true if this connection has been released and wont be reused. |
| public boolean | |
| public void | lock()
Locks the connection only if either |
| public void | reconnect()
Issues a call to |
| public boolean | Returns: true if this is the first time this method has been called. false if this method has been called before.This method is called if (Now - timeCheckedIn > getReleaseTime())
This method disconnects the connection, logs an error in debug mode if it happens
then sets the |
| public void | setDiscarded(boolean
- only valid value is true discarded)An interceptor can call this method with the value true, and the connection will be closed when it is returned to the pool. |
| public void | |
| public void | setLastValidated(long
a timestamp as defined by lastValidated)System#currentTimeMillis()Set the timestamp the connection was last validated. |
| public void | setPoolProperties(PoolConfiguration
The pool properties poolProperties)Sets the pool configuration for this connection and connection pool. |
| public void | setStackTrace(String
the stack trace for this connection trace)The pool will set the stack trace when it is check out and checked in |
| public void | |
| public void | setTimestamp(long
the timestamp as defined by timestamp)System#currentTimeMillis()Sets a timestamp on this connection. |
| public boolean | Returns: true is the pool must reconnectthe username you wish to connect with, pass in null to accept the default username from username, String PoolConfiguration#getUsername()the password you wish to connect with, pass in null to accept the default username from password)org.Returns true if we must force reconnect based on credentials passed in.
Returns false if |
| private boolean | |
| private boolean | |
| public String | |
| public void | unlock()
Unlocks the connection only if the sweeper is enabled Otherwise this is a noop for performance |
| public boolean | Returns: true if the connection is validThe value validateAction)Returns |
| public boolean | Returns: true if the connection was validated successfully. It returns true even if validation was not performed, such as whenPoolConfiguration#setValidationInterval(long) has been called with a positive value.
false if the validation failed. The caller should close the connection if false is returned since a session could have been left in an unknown state during initialization. the SQL to be used during validation. If the sql)PoolConfiguration#setInitSQL(String) has been called with a non null
value and the action is VALIDATE_INIT the init SQL will be used for validation.Validates a connection. |
| abandonTrace | back to summary |
|---|---|
| private String abandonTrace When we track abandon traces, this string holds the thread dump | |
| attributes | back to summary |
|---|---|
| private HashMap<Object, Object> attributes | |
| connection | back to summary |
|---|---|
| private volatile Connection connection The underlying database connection | |
| connectionIndex | back to summary |
|---|---|
| private static final AtomicLong connectionIndex | |
| connectionVersion | back to summary |
|---|---|
| private volatile long connectionVersion | |
| discarded | back to summary |
|---|---|
| private volatile boolean discarded Set to true if this connection has been discarded by the pool | |
| driver | back to summary |
|---|---|
| private Driver driver | |
| handler | back to summary |
|---|---|
| private volatile JdbcInterceptor handler Weak reference to cache the list of interceptors for this connection so that we don't create a new list of interceptors each time we borrow the connection | |
| lastConnected | back to summary |
|---|---|
| private volatile long lastConnected The Timestamp when the last time the connect() method was called successfully | |
| lastValidated | back to summary |
|---|---|
| private volatile long lastValidated timestamp to keep track of validation intervals | |
| lock | back to summary |
|---|---|
| private final ReentrantReadWriteLock lock Lock for this connection only | |
| log | back to summary |
|---|---|
| private static final Log log Logger | |
| oname | back to summary |
|---|---|
| private ObjectName oname | |
| parent | back to summary |
|---|---|
| protected ConnectionPool parent The parent | |
| poolProperties | back to summary |
|---|---|
| protected PoolConfiguration poolProperties The properties for the connection pool | |
| PROP_PASSWORD | back to summary |
|---|---|
| public static final String PROP_PASSWORD | |
| PROP_USER | back to summary |
|---|---|
| public static final String PROP_USER | |
| released | back to summary |
|---|---|
| private AtomicBoolean released | |
| suspect | back to summary |
|---|---|
| private volatile boolean suspect | |
| timestamp | back to summary |
|---|---|
| private volatile long timestamp Timestamp the connection was last 'touched' by the pool | |
| VALIDATE_BORROW | back to summary |
|---|---|
| public static final int VALIDATE_BORROW Validate when connection is borrowed flag | |
| VALIDATE_IDLE | back to summary |
|---|---|
| public static final int VALIDATE_IDLE Validate when connection is idle flag | |
| VALIDATE_INIT | back to summary |
|---|---|
| public static final int VALIDATE_INIT Validate when connection is initialized flag | |
| VALIDATE_RETURN | back to summary |
|---|---|
| public static final int VALIDATE_RETURN Validate when connection is returned flag | |
| xaConnection | back to summary |
|---|---|
| protected volatile XAConnection xaConnection If using a XAConnection underneath. | |
| PooledConnection | back to summary |
|---|---|
| public PooledConnection(PoolConfiguration prop, ConnectionPool parent) Constructor
| |
| checkUser | back to summary |
|---|---|
| public boolean checkUser(String username, String password)
Deprecated use
| |
| clearWarnings | back to summary |
|---|---|
| public void clearWarnings() Implements org.
| |
| connect | back to summary |
|---|---|
| public void connect() throws SQLException Connects the underlying connection to the database.
| |
| connectUsingDataSource | back to summary |
|---|---|
| protected void connectUsingDataSource() throws SQLException | |
| connectUsingDriver | back to summary |
|---|---|
| protected void connectUsingDriver() throws SQLException | |
| createMBean | back to summary |
|---|---|
| public void createMBean() | |
| disconnect | back to summary |
|---|---|
| private void disconnect(boolean finalize) Disconnects the connection. All exceptions are logged using debug level.
| |
| doValidate | back to summary |
|---|---|
| private boolean doValidate(int action) Returns
| |
| getAbandonTimeout | back to summary |
|---|---|
| public long getAbandonTimeout() Returns abandon timeout in milliseconds
| |
| getAttributes | back to summary |
|---|---|
| public HashMap | |
| getAutoCommit | back to summary |
|---|---|
| public boolean getAutoCommit() throws SQLException Implements org.
| |
| getCatalog | back to summary |
|---|---|
| public String getCatalog() throws SQLException Implements org.
| |
| getConnection | back to summary |
|---|---|
| public Connection getConnection() Returns the underlying connection
| |
| getConnectionVersion | back to summary |
|---|---|
| public long getConnectionVersion() Implements org.
| |
| getHandler | back to summary |
|---|---|
| public JdbcInterceptor getHandler() Returns the first handler in the interceptor chain
| |
| getHoldability | back to summary |
|---|---|
| public int getHoldability() throws SQLException Implements org.
| |
| getLastConnected | back to summary |
|---|---|
| public long getLastConnected() Implements org. Returns the timestamp of when the connection was last connected to the database.
ie, a successful call to
| |
| getLastValidated | back to summary |
|---|---|
| public long getLastValidated() Implements org. Returns the timestamp of the last successful validation query execution.
| |
| getObjectName | back to summary |
|---|---|
| public ObjectName getObjectName() | |
| getPoolProperties | back to summary |
|---|---|
| public PoolConfiguration getPoolProperties() Returns the configuration for this connection and pool
| |
| getReleaseTime | back to summary |
|---|---|
| public long getReleaseTime() The time limit for how long the object can remain unused before it is released | |
| getSchema | back to summary |
|---|---|
| public String getSchema() throws SQLException Implements org.
| |
| getStackTrace | back to summary |
|---|---|
| public String getStackTrace() Returns the stack trace from when this connection was borrowed. Can return null if no stack trace was set.
| |
| getTimestamp | back to summary |
|---|---|
| public long getTimestamp() Implements org. Return the timestamps of last pool action. Timestamps are typically set when connections
are borrowed from the pool. It is used to keep track of
| |
| getTransactionIsolation | back to summary |
|---|---|
| public int getTransactionIsolation() throws SQLException Implements org.
| |
| getXAConnection | back to summary |
|---|---|
| public XAConnection getXAConnection() Returns the underlying XA connection
| |
| isClosed | back to summary |
|---|---|
| public boolean isClosed() throws SQLException Implements org.
| |
| isDiscarded | back to summary |
|---|---|
| public boolean isDiscarded() Implements org. Returns the discarded flag.
| |
| isInitialized | back to summary |
|---|---|
| public boolean isInitialized() Implements org.
| |
| isMaxAgeExpired | back to summary |
|---|---|
| public boolean isMaxAgeExpired() Implements org. Returns true if the connection has been connected more than
| |
| isReadOnly | back to summary |
|---|---|
| public boolean isReadOnly() throws SQLException Implements org.
| |
| isReleased | back to summary |
|---|---|
| public boolean isReleased() Implements org. Returns true if this connection has been released and wont be reused. | |
| isSuspect | back to summary |
|---|---|
| public boolean isSuspect() Implements org.
| |
| lock | back to summary |
|---|---|
| public void lock() Locks the connection only if either | |
| reconnect | back to summary |
|---|---|
| public void reconnect() throws SQLException Issues a call to
| |
| release | back to summary |
|---|---|
| public boolean release() This method is called if (Now - timeCheckedIn > getReleaseTime())
This method disconnects the connection, logs an error in debug mode if it happens
then sets the
| |
| setDiscarded | back to summary |
|---|---|
| public void setDiscarded(boolean discarded) An interceptor can call this method with the value true, and the connection will be closed when it is returned to the pool.
| |
| setHandler | back to summary |
|---|---|
| public void setHandler(JdbcInterceptor handler) | |
| setLastValidated | back to summary |
|---|---|
| public void setLastValidated(long lastValidated) Set the timestamp the connection was last validated.
This flag is used to keep track when we are using a
| |
| setPoolProperties | back to summary |
|---|---|
| public void setPoolProperties(PoolConfiguration poolProperties) Sets the pool configuration for this connection and connection pool.
Object is shared with the
| |
| setStackTrace | back to summary |
|---|---|
| public void setStackTrace(String trace) The pool will set the stack trace when it is check out and checked in
| |
| setSuspect | back to summary |
|---|---|
| public void setSuspect(boolean suspect) | |
| setTimestamp | back to summary |
|---|---|
| public void setTimestamp(long timestamp) Sets a timestamp on this connection. A timestamp usually means that some operation performed successfully.
| |
| shouldForceReconnect | back to summary |
|---|---|
| public boolean shouldForceReconnect(String username, String password) Returns true if we must force reconnect based on credentials passed in.
Returns false if
| |
| silentlyCommitTransactionIfNeeded | back to summary |
|---|---|
| private boolean silentlyCommitTransactionIfNeeded() | |
| silentlyRollbackTransactionIfNeeded | back to summary |
|---|---|
| private boolean silentlyRollbackTransactionIfNeeded() | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| unlock | back to summary |
|---|---|
| public void unlock() Unlocks the connection only if the sweeper is enabled Otherwise this is a noop for performance | |
| validate | back to summary |
|---|---|
| public boolean validate(int validateAction) Returns
| |
| validate | back to summary |
|---|---|
| public boolean validate(int validateAction, String sql) Validates a connection.
| |