public class JDBCUniversalPooledConnection
extends oracle.ucp.common.FailoverableUniversalPooledConnectionBase
Modifier and Type | Field and Description |
---|---|
static long |
CONNECTION_VALIDATION_TIMEOUT |
protected Semaphore |
validitySemaphore |
Constructor and Description |
---|
JDBCUniversalPooledConnection(JDBCConnectionPool connectionPool,
Object connection,
ConnectionRetrievalInfo connectionRetrievalInfo,
boolean connectionFailoverEnabled) |
Modifier and Type | Method and Description |
---|---|
void |
abort()
TODO document
abort connection
|
void |
applyConnectionLabel(String key,
String value)
Connection labels can be applied on a borrowed connection by calling
this method at any time when the connection remains open.
|
void |
close()
TODO document
close connection
|
AbandonedConnectionTimeoutCallback |
getAbandonedConnectionTimeoutCallback()
Obtains the AbandonedConnectionTimeoutCallback registered with this
connection.
|
long |
getAvailableStartTime()
Gets the time that this pooled connection became available.
|
long |
getBorrowedStartTime()
Gets the timestamp that this pooled connection became borrowed.
|
ConnectionHarvestingCallback |
getConnectionHarvestingCallback()
Obtains the ConnectionHarvestingCallback registered with this
connection.
|
Properties |
getConnectionLabels()
Retrieves all the connection labels applied on this connection.
|
ConnectionRetrievalInfo |
getConnectionRetrievalInfo()
Gets the connection retrieval info.
|
int |
getConnectionReuseCounter()
Gets the connection reuse counter.
|
long |
getConnectionReuseTimestamp()
Gets the connection reuse timestamp.
|
Properties |
getDatabaseConnectionProperties()
Fetches the connection properties.
|
oracle.ucp.common.CoreConnection |
getDelegator() |
long |
getLastAccessedTime()
Gets the last time, in milliseconds, that this pooled connection was
used by the client.
|
long |
getLastConnectionValidationTime()
Gets the time that this pooled connection was last validated.
|
long |
getLastNetworkAccessTime()
Gets the time (in milliseconds) when the underlying connection last
accessed the network.
|
int |
getMaxStatements()
Gets the maximum number of statements that may be pooled or cached on a
Connection.
|
Object |
getPhysicalConnection()
Gets the connection.
|
String |
getService() |
Connection |
getSQLConnection(Object physicalConnection) |
UniversalPooledConnectionStatus |
getStatus()
Gets the status of the pooled connection.
|
TimeToLiveConnectionTimeoutCallback |
getTimeToLiveConnectionTimeoutCallback()
Obtains the TimeToLiveConnectionTimeoutCallback registered with this
connection.
|
Properties |
getUnmatchedConnectionLabels(Properties requestedLabels)
Obtains all the requested labels that did not match the applied
labels on this connection, when this connection was borrowed from
the pool.
|
void |
handleTimeout()
TODO document
handle timeouts on connection
|
void |
heartbeat()
This method is to be called to indicate that the pooled connection
is alive and being used.
|
protected void |
initFailoverParameters()
Initializes the failover properties on this Universal Pooled Connection.
|
boolean |
isAvailable()
check whether a connection is "available" or not
|
boolean |
isConnectionHarvestable()
Whether this connection is currently harvestable.
|
boolean |
isReusable()
check whether a connection is "reusable" or not
|
boolean |
isSqlWithQueryTimeoutInProgress()
Checks whether or not the connection currently performing timed-out SQL operation
|
boolean |
isValid()
This method is called to check if the connection is valid or not.
|
boolean |
isValid(long timeout)
This method is called to check if the connection is valid or not.
|
int |
labelingCost(Properties labels)
Get a cost for labeling a connection up to a
required set of labels in the given CRI
This is unified method:
i.e.
|
void |
plugDelegator(oracle.ucp.common.CoreConnection delegator) |
void |
registerAbandonedConnectionTimeoutCallback(AbandonedConnectionTimeoutCallback cbk)
Registers an AbandonedConnectionTimeoutCallback with this
connection.
|
void |
registerConnectionHarvestingCallback(ConnectionHarvestingCallback cbk)
Registers a ConnectionHarvestingCallback with this connection.
|
void |
registerTimeToLiveConnectionTimeoutCallback(TimeToLiveConnectionTimeoutCallback cbk)
Registers a TimeToLiveConnectionTimeoutCallback with this
connection.
|
void |
removeAbandonedConnectionTimeoutCallback()
Removes the AbandonedConnectionTimeoutCallback object registered with
this connection, if any.
|
void |
removeConnectionHarvestingCallback()
Removes the ConnectionHarvestingCallback object registered with this
connection, if any.
|
void |
removeConnectionLabel(String key)
Removes the connection label with the given key from the connection
labels applied on this connection.
|
void |
removeTimeToLiveConnectionTimeoutCallback()
Removes the TimeToLiveConnectionTimeoutCallback object registered
with this connection, if any.
|
boolean |
setAvailable()
mark connection as "available"
|
void |
setAvailableStartTime()
Sets the time that this pooled connection became available.
|
boolean |
setBorrowed()
mark connection as "borrowed"
|
void |
setBorrowedStartTime()
Sets the time that this pooled connection became borrowed to be the
current system time.
|
void |
setConnectionHarvestable(boolean isConnectionHarvestable)
Specifies whether this connection is harvestable.
|
void |
setConnectionRetrievalInfo(ConnectionRetrievalInfo newCri)
Sets the connection retrieval info on the connection.
|
void |
setLastConnectionValidationTime(long lastConnectionValidationTime)
Sets or resets the time when this pooled connection was last validated.
|
void |
setMaxStatements(int maxStatements)
Sets the maximum number of statements that may be pooled or cached on
a connection.
|
boolean |
setShardingKeyIfValid(OracleShardingKey key,
OracleShardingKey superKey,
int timeout)
No implementation in base class, will be implemented in Oracle specific
connection class.
|
void |
setSqlWithQueryTimeoutInProgress(boolean sqlWithQueryTimeoutInProgress)
Marks connection currently performing timed-out SQL operation
|
void |
setStatus(UniversalPooledConnectionStatus status)
Sets the status of the pooled connection.
|
void |
setStatus(UniversalPooledConnectionStatus status,
String msg) |
void |
validate()
Validates this connection and sets corresponding status on this
connection.
|
public static final long CONNECTION_VALIDATION_TIMEOUT
protected final Semaphore validitySemaphore
public JDBCUniversalPooledConnection(JDBCConnectionPool connectionPool, Object connection, ConnectionRetrievalInfo connectionRetrievalInfo, boolean connectionFailoverEnabled) throws UniversalConnectionPoolException
UniversalConnectionPoolException
public void validate()
validate
in interface UniversalPooledConnection
public boolean setShardingKeyIfValid(OracleShardingKey key, OracleShardingKey superKey, int timeout)
key
- superKey
- timeout
- public Connection getSQLConnection(Object physicalConnection) throws SQLException
SQLException
protected void initFailoverParameters() throws UniversalConnectionPoolException
oracle.ucp.common.FailoverableUniversalPooledConnectionBase
initFailoverParameters
in class oracle.ucp.common.FailoverableUniversalPooledConnectionBase
UniversalConnectionPoolException
public int getMaxStatements()
public void setMaxStatements(int maxStatements) throws SQLException
maxStatements
- maximum number of statements to be pooled.SQLException
- Exception occurred during the process of setting
maximum statements that may be pooled on a connection.public Object getPhysicalConnection()
getPhysicalConnection
in interface UniversalPooledConnection
public ConnectionRetrievalInfo getConnectionRetrievalInfo()
getConnectionRetrievalInfo
in interface UniversalPooledConnection
public void setConnectionRetrievalInfo(ConnectionRetrievalInfo newCri)
UniversalPooledConnection
setConnectionRetrievalInfo
in interface UniversalPooledConnection
newCri
- -new CRI to be used for this connectionpublic void heartbeat()
heartbeat
in interface UniversalPooledConnection
public void setSqlWithQueryTimeoutInProgress(boolean sqlWithQueryTimeoutInProgress)
setSqlWithQueryTimeoutInProgress
in interface UniversalPooledConnection
set
- true if timed-out SQL operation is in progresspublic boolean isSqlWithQueryTimeoutInProgress()
isSqlWithQueryTimeoutInProgress
in interface UniversalPooledConnection
public boolean isValid()
isValid
in interface UniversalPooledConnection
public boolean isValid(long timeout) throws SQLException
timeout
- connection validation timeout in seconds.SQLException
public long getLastNetworkAccessTime()
getLastNetworkAccessTime
in interface UniversalPooledConnection
public long getLastAccessedTime()
getLastAccessedTime
in interface UniversalPooledConnection
public UniversalPooledConnectionStatus getStatus()
getStatus
in interface UniversalPooledConnection
public void setStatus(UniversalPooledConnectionStatus status) throws UniversalConnectionPoolException
setStatus
in interface UniversalPooledConnection
status
- The status of the pooled connection.UniversalConnectionPoolException
- if an error occurs setting the status.public void setStatus(UniversalPooledConnectionStatus status, String msg)
public long getAvailableStartTime()
getAvailableStartTime
in interface UniversalPooledConnection
public void setAvailableStartTime()
setAvailableStartTime
in interface UniversalPooledConnection
public long getBorrowedStartTime()
getBorrowedStartTime
in interface UniversalPooledConnection
public void setBorrowedStartTime()
setBorrowedStartTime
in interface UniversalPooledConnection
public long getLastConnectionValidationTime()
getLastConnectionValidationTime
in interface UniversalPooledConnection
public void setLastConnectionValidationTime(long lastConnectionValidationTime)
setLastConnectionValidationTime
in interface UniversalPooledConnection
public void applyConnectionLabel(String key, String value) throws UniversalConnectionPoolException
applyConnectionLabel
in interface UniversalPooledConnection
key
- The key of the connection label to be applied. Cannot
be null or an empty string.value
- The value of the connection label to be applied. Can be
null or an empty string.UniversalConnectionPoolException
- If this connection was closed
or the key is null or an empty
string.public void removeConnectionLabel(String key) throws UniversalConnectionPoolException
removeConnectionLabel
in interface UniversalPooledConnection
key
- The key of the connection label to be removed. Cannot be
null or an empty string.UniversalConnectionPoolException
- If this connection was closed
or the key is null or an empty
string.public Properties getConnectionLabels() throws UniversalConnectionPoolException
getConnectionLabels
in interface UniversalPooledConnection
UniversalConnectionPoolException
- If this connection was
closed.public Properties getUnmatchedConnectionLabels(Properties requestedLabels) throws UniversalConnectionPoolException
getUnmatchedConnectionLabels
in interface UniversalPooledConnection
requestedLabels
- The requested labels that borrowed this
connection from the pool.UniversalConnectionPoolException
- If this connection was
closed.public void setConnectionHarvestable(boolean isConnectionHarvestable) throws UniversalConnectionPoolException
setConnectionHarvestable
in interface UniversalPooledConnection
isConnectionHarvestable
- Whether this connection is
harvestable.UniversalConnectionPoolException
- If this connection was
closed.public boolean isConnectionHarvestable()
isConnectionHarvestable
in interface UniversalPooledConnection
public void registerConnectionHarvestingCallback(ConnectionHarvestingCallback cbk) throws UniversalConnectionPoolException
registerConnectionHarvestingCallback
in interface UniversalPooledConnection
cbk
- The ConnectionHarvestingCallback object to be
registered.UniversalConnectionPoolException
- If there is a callback already
registered with the connection.public void removeConnectionHarvestingCallback() throws UniversalConnectionPoolException
removeConnectionHarvestingCallback
in interface UniversalPooledConnection
UniversalConnectionPoolException
- If callback removal fails.public ConnectionHarvestingCallback getConnectionHarvestingCallback() throws UniversalConnectionPoolException
getConnectionHarvestingCallback
in interface UniversalPooledConnection
UniversalConnectionPoolException
- If an error occurs.public void registerAbandonedConnectionTimeoutCallback(AbandonedConnectionTimeoutCallback cbk) throws UniversalConnectionPoolException
registerAbandonedConnectionTimeoutCallback
in interface UniversalPooledConnection
cbk
- The AbandonedConnectionTimeoutCallback object to be
registered.UniversalConnectionPoolException
- If there is a callback already
registered with the connection.public void removeAbandonedConnectionTimeoutCallback() throws UniversalConnectionPoolException
removeAbandonedConnectionTimeoutCallback
in interface UniversalPooledConnection
UniversalConnectionPoolException
- If callback removal fails.public AbandonedConnectionTimeoutCallback getAbandonedConnectionTimeoutCallback() throws UniversalConnectionPoolException
getAbandonedConnectionTimeoutCallback
in interface UniversalPooledConnection
UniversalConnectionPoolException
- If an error occurs.public void registerTimeToLiveConnectionTimeoutCallback(TimeToLiveConnectionTimeoutCallback cbk) throws UniversalConnectionPoolException
registerTimeToLiveConnectionTimeoutCallback
in interface UniversalPooledConnection
cbk
- The TimeToLiveConnectionTimeoutCallback object to be
registered.UniversalConnectionPoolException
- If there is a callback already
registered with the connection.public void removeTimeToLiveConnectionTimeoutCallback() throws UniversalConnectionPoolException
removeTimeToLiveConnectionTimeoutCallback
in interface UniversalPooledConnection
UniversalConnectionPoolException
- If callback removal fails.public TimeToLiveConnectionTimeoutCallback getTimeToLiveConnectionTimeoutCallback() throws UniversalConnectionPoolException
getTimeToLiveConnectionTimeoutCallback
in interface UniversalPooledConnection
UniversalConnectionPoolException
- If an error occurs.public int getConnectionReuseCounter()
public long getConnectionReuseTimestamp()
public boolean isReusable()
UniversalPooledConnection
isReusable
in interface UniversalPooledConnection
public void close()
UniversalPooledConnection
close
in interface Closeable
close
in interface AutoCloseable
close
in interface UniversalPooledConnection
public void abort()
UniversalPooledConnection
abort
in interface UniversalPooledConnection
public void handleTimeout()
UniversalPooledConnection
handleTimeout
in interface UniversalPooledConnection
public boolean isAvailable()
UniversalPooledConnection
isAvailable
in interface UniversalPooledConnection
public boolean setAvailable()
UniversalPooledConnection
setAvailable
in interface UniversalPooledConnection
public boolean setBorrowed()
UniversalPooledConnection
setBorrowed
in interface UniversalPooledConnection
public int labelingCost(Properties labels)
labelingCost
in interface UniversalPooledConnection
public void plugDelegator(oracle.ucp.common.CoreConnection delegator)
plugDelegator
in interface UniversalPooledConnection
public oracle.ucp.common.CoreConnection getDelegator()
getDelegator
in interface UniversalPooledConnection
public String getService()
public Properties getDatabaseConnectionProperties()
getDatabaseConnectionProperties
in interface UniversalPooledConnection
Copyright © 2008, 2017, Oracle. All rights reserved.