Class PooledConnection
java.lang.Object
org.apache.ibatis.datasource.pooled.PooledConnection
- All Implemented Interfaces:
InvocationHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate static final Stringprivate intprivate longprivate final PooledDataSourceprivate final intprivate static final Class<?>[]private longprivate final Connectionprivate final Connectionprivate boolean -
Constructor Summary
ConstructorsConstructorDescriptionPooledConnection(Connection connection, PooledDataSource dataSource) Constructor for SimplePooledConnection that uses the Connection and PooledDataSource passed in. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidbooleanAllows comparing this connection to another.longgetAge()Getter for the age of the connection.longGetter for the time that this connection has been checked out.longGetter for the timestamp that this connection was checked out.intGetter for the connection type (based on url + user + password).longGetter for the time that the connection was created.longGetter for the time that the connection was last used.Getter for the proxy for the connection.Getter for the *real* connection that this wraps.intGets the hashcode of the real connection (or 0 if it is null).longGetter for the time since this connection was last used.inthashCode()voidInvalidates the connection.Required for InvocationHandler implementation.booleanisValid()Method to see if the connection is usable.voidsetCheckoutTimestamp(long timestamp) Setter for the timestamp that this connection was checked out.voidsetConnectionTypeCode(int connectionTypeCode) Setter for the connection type.voidsetCreatedTimestamp(long createdTimestamp) Setter for the time that the connection was created.voidsetLastUsedTimestamp(long lastUsedTimestamp) Setter for the time that the connection was last used.
-
Field Details
-
CLOSE
- See Also:
-
IFACES
-
hashCode
private final int hashCode -
dataSource
-
realConnection
-
proxyConnection
-
checkoutTimestamp
private long checkoutTimestamp -
createdTimestamp
private long createdTimestamp -
lastUsedTimestamp
private long lastUsedTimestamp -
connectionTypeCode
private int connectionTypeCode -
valid
private boolean valid
-
-
Constructor Details
-
PooledConnection
Constructor for SimplePooledConnection that uses the Connection and PooledDataSource passed in.- Parameters:
connection- - the connection that is to be presented as a pooled connectiondataSource- - the dataSource that the connection is from
-
-
Method Details
-
invalidate
public void invalidate()Invalidates the connection. -
isValid
public boolean isValid()Method to see if the connection is usable.- Returns:
- True if the connection is usable
-
getRealConnection
Getter for the *real* connection that this wraps.- Returns:
- The connection
-
getProxyConnection
Getter for the proxy for the connection.- Returns:
- The proxy
-
getRealHashCode
public int getRealHashCode()Gets the hashcode of the real connection (or 0 if it is null).- Returns:
- The hashcode of the real connection (or 0 if it is null)
-
getConnectionTypeCode
public int getConnectionTypeCode()Getter for the connection type (based on url + user + password).- Returns:
- The connection type
-
setConnectionTypeCode
public void setConnectionTypeCode(int connectionTypeCode) Setter for the connection type.- Parameters:
connectionTypeCode- - the connection type
-
getCreatedTimestamp
public long getCreatedTimestamp()Getter for the time that the connection was created.- Returns:
- The creation timestamp
-
setCreatedTimestamp
public void setCreatedTimestamp(long createdTimestamp) Setter for the time that the connection was created.- Parameters:
createdTimestamp- - the timestamp
-
getLastUsedTimestamp
public long getLastUsedTimestamp()Getter for the time that the connection was last used.- Returns:
- - the timestamp
-
setLastUsedTimestamp
public void setLastUsedTimestamp(long lastUsedTimestamp) Setter for the time that the connection was last used.- Parameters:
lastUsedTimestamp- - the timestamp
-
getTimeElapsedSinceLastUse
public long getTimeElapsedSinceLastUse()Getter for the time since this connection was last used.- Returns:
- - the time since the last use
-
getAge
public long getAge()Getter for the age of the connection.- Returns:
- the age
-
getCheckoutTimestamp
public long getCheckoutTimestamp()Getter for the timestamp that this connection was checked out.- Returns:
- the timestamp
-
setCheckoutTimestamp
public void setCheckoutTimestamp(long timestamp) Setter for the timestamp that this connection was checked out.- Parameters:
timestamp- the timestamp
-
getCheckoutTime
public long getCheckoutTime()Getter for the time that this connection has been checked out.- Returns:
- the time
-
hashCode
public int hashCode() -
equals
Allows comparing this connection to another. -
invoke
Required for InvocationHandler implementation.- Specified by:
invokein interfaceInvocationHandler- Parameters:
proxy- - not usedmethod- - the method to be executedargs- - the parameters to be passed to the method- Throws:
Throwable- See Also:
-
checkConnection
- Throws:
SQLException
-