Class PooledConnection
- java.lang.Object
-
- org.apache.ibatis.datasource.pooled.PooledConnection
-
- All Implemented Interfaces:
java.lang.reflect.InvocationHandler
class PooledConnection extends java.lang.Object implements java.lang.reflect.InvocationHandler
-
-
Field Summary
Fields Modifier and Type Field Description private long
checkoutTimestamp
private static java.lang.String
CLOSE
private int
connectionTypeCode
private long
createdTimestamp
private PooledDataSource
dataSource
private int
hashCode
private static java.lang.Class<?>[]
IFACES
private long
lastUsedTimestamp
private java.sql.Connection
proxyConnection
private java.sql.Connection
realConnection
private boolean
valid
-
Constructor Summary
Constructors Constructor Description PooledConnection(java.sql.Connection connection, PooledDataSource dataSource)
Constructor for SimplePooledConnection that uses the Connection and PooledDataSource passed in.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkConnection()
boolean
equals(java.lang.Object obj)
Allows comparing this connection to another.long
getAge()
Getter for the age of the connection.long
getCheckoutTime()
Getter for the time that this connection has been checked out.long
getCheckoutTimestamp()
Getter for the timestamp that this connection was checked out.int
getConnectionTypeCode()
Getter for the connection type (based on url + user + password).long
getCreatedTimestamp()
Getter for the time that the connection was created.long
getLastUsedTimestamp()
Getter for the time that the connection was last used.java.sql.Connection
getProxyConnection()
Getter for the proxy for the connection.java.sql.Connection
getRealConnection()
Getter for the *real* connection that this wraps.int
getRealHashCode()
Gets the hashcode of the real connection (or 0 if it is null).long
getTimeElapsedSinceLastUse()
Getter for the time since this connection was last used.int
hashCode()
void
invalidate()
Invalidates the connection.java.lang.Object
invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
Required for InvocationHandler implementation.boolean
isValid()
Method to see if the connection is usable.void
setCheckoutTimestamp(long timestamp)
Setter for the timestamp that this connection was checked out.void
setConnectionTypeCode(int connectionTypeCode)
Setter for the connection type.void
setCreatedTimestamp(long createdTimestamp)
Setter for the time that the connection was created.void
setLastUsedTimestamp(long lastUsedTimestamp)
Setter for the time that the connection was last used.
-
-
-
Field Detail
-
CLOSE
private static final java.lang.String CLOSE
- See Also:
- Constant Field Values
-
IFACES
private static final java.lang.Class<?>[] IFACES
-
hashCode
private final int hashCode
-
dataSource
private final PooledDataSource dataSource
-
realConnection
private final java.sql.Connection realConnection
-
proxyConnection
private final java.sql.Connection proxyConnection
-
checkoutTimestamp
private long checkoutTimestamp
-
createdTimestamp
private long createdTimestamp
-
lastUsedTimestamp
private long lastUsedTimestamp
-
connectionTypeCode
private int connectionTypeCode
-
valid
private boolean valid
-
-
Constructor Detail
-
PooledConnection
public PooledConnection(java.sql.Connection connection, PooledDataSource dataSource)
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 Detail
-
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
public java.sql.Connection getRealConnection()
Getter for the *real* connection that this wraps.- Returns:
- The connection
-
getProxyConnection
public java.sql.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()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
Allows comparing this connection to another.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- - the other connection to test for equality- See Also:
Object.equals(Object)
-
invoke
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable
Required for InvocationHandler implementation.- Specified by:
invoke
in interfacejava.lang.reflect.InvocationHandler
- Parameters:
proxy
- - not usedmethod
- - the method to be executedargs
- - the parameters to be passed to the method- Throws:
java.lang.Throwable
- See Also:
InvocationHandler.invoke(Object, java.lang.reflect.Method, Object[])
-
checkConnection
private void checkConnection() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
-