public interface UniversalConnectionPool
UniversalPooledConnection
object that is then placed into
the connection pool. When the connection pool closes a connection, it
hands the connection to the connection factory adapter which then closes
the connection.
Pooled Connections Each pooled connection in the connection pool is
an instance of UniversalPooledConnection
. The pooled connection
decorates a physical connection (created by the connection factory adapter) which
can be borrowed.
Connection Retrieval Info The connection retrieval info object is
used by the connection factory adapter to create connections. It contains
resource-specific information that the connection factory adapter uses
to create connections. For example, the JDBC connection retrieval
info object maintains the user and password that are used to create a
connection from a JDBC resource. The JCA connection retrieval info
object maintains the Subject
and JCA
ConnectionRequestInfo object
.
Pool Properties The pool provides some properties for users to
customize the pool's behavior, such as:
UniversalConnectionPoolLifeCycleState
for details.
A connection pool is started by calling the start()
method and
stopped by calling the stop()
method. Connections may not be
borrowed until the connection pool has been started or after the pool has
been stopped (unless the pool has been started again).
Modifier and Type | Method and Description |
---|---|
UniversalPooledConnection |
borrowConnection(ConnectionRetrievalInfo connectionRetrievalInfo)
Gets a connection from the connection pool.
|
void |
closeConnection(UniversalPooledConnection pooledConnection)
Closes the pooled connection.
|
int |
getAbandonedConnectionTimeout()
Gets the abandoned connection timeout value.
|
int |
getAvailableConnectionsCount()
Gets the number of connections that are available in the connection
pool (that is, connections in the pool that are not currently in use by
clients).
|
int |
getBorrowedConnectionsCount()
Gets the number of connections that are actively in use by clients.
|
int |
getConnectionHarvestMaxCount()
Gets the maximum number of connections that may be harvested when
the connection harvesting occurs.
|
int |
getConnectionHarvestTriggerCount()
Gets the number of available connections below which the connection
pool's connection harvesting occurs.
|
int |
getConnectionLabelingHighCost()
Obtains the cost value which identifies a connection as "high-cost"
for connection labeling.
|
int |
getConnectionRepurposeThreshold()
Gets the connection repurpose threshold for the pool.
|
ConnectionRetrievalInfo |
getConnectionRetrievalInfo()
Gets the
ConnectionRetrievalInfo object which contains
user and password information to create the connections. |
int |
getConnectionWaitTimeout()
Gets the amount of time to wait (in seconds) for a used connection to
be released by a client.
|
int |
getHighCostConnectionReuseThreshold()
Obtains the high-cost connection reuse threshold property
value for connection labeling.
|
int |
getInactiveConnectionTimeout()
Gets the inactive connection timeout value.
|
int |
getInitialPoolSize()
Gets the initial pool size.
|
UniversalConnectionPoolLifeCycleState |
getLifeCycleState()
Gets the life cycle state of the connection pool.
|
int |
getLoginTimeout()
Gets the default maximum time in seconds that a driver will wait while attempting
to connect to a database once the driver has been identified.
|
int |
getMaxConnectionReuseCount()
Gets the maximum connection reuse count property value.
|
long |
getMaxConnectionReuseTime()
Gets the maximum connection reuse time property value.
|
int |
getMaxConnectionsPerService()
Gets the maximum number of connections that can be obtained to a particular
service, in a shared pool.
|
int |
getMaxPoolSize()
Gets the maximum number of connections that the connection pool
maintains.
|
int |
getMinPoolSize()
Gets the minimum number of connections that the connection pool
maintains.
|
String |
getName()
Gets the name of the connection pool.
|
int |
getSecondsToTrustIdleConnection()
Gets the seconds To Trust Idle Connection value which determines whether
or not connection validation on borrow should be skipped
See property description in
setSecondsToTrustIdleConnection() . |
UniversalConnectionPoolStatistics |
getStatistics()
Gets the statistics of the connection pool.
|
int |
getTimeoutCheckInterval()
Gets the frequency (in seconds) to enforce the timeout properties.
|
int |
getTimeToLiveConnectionTimeout()
Gets the maximum time (in seconds) a connection may remain in-use.
|
boolean |
getValidateConnectionOnBorrow()
Returns whether or not a connection being borrowed should first be
validated.
|
boolean |
isShareable()
Returns whether the pool is shareable or not.
|
void |
purge()
Removes all connections from the connection pool.
|
void |
reconfigure(Properties props)
Allows a connection pool to be reconfigured gracefully with a
different set of properties that specify the behavior of the
connection pool at runtime.
|
void |
recycle()
Allows only invalid available connections
in the pool to be replaced with new/fresh connections.
|
void |
refresh()
Allows connections in the pool, both borrowed and available ones,
to be replaced with new/fresh connections.
|
void |
registerConnectionAffinityCallback(ConnectionAffinityCallback cbk)
Registers a
ConnectionAffinityCallback objet on the
connection pool. |
void |
registerConnectionLabelingCallback(ConnectionLabelingCallback cbk)
Registers a
ConnectionLabelingCallback object with this
connection pool. |
void |
removeConnectionAffinityCallback()
Removes the
ConnectionAffinityCallback object registered on
the connection pool. |
void |
removeConnectionLabelingCallback()
Removes the
ConnectionLabelingCallback object registered
with this connection pool, if any. |
void |
returnConnection(UniversalPooledConnection pooledConnection)
Returns a connection back into the connection pool.
|
void |
setAbandonedConnectionTimeout(int abandonedConnectionTimeout)
Sets the abandoned connection timeout.
|
void |
setConnectionHarvestMaxCount(int connectionHarvestMaxCount)
Sets the maximum number of connections that may be harvested when
the connection harvesting occurs.
|
void |
setConnectionHarvestTriggerCount(int connectionHarvestTriggerCount)
Sets the number of available connections below which the connection
pool's connection harvesting occurs.
|
void |
setConnectionLabelingHighCost(int highCost)
Sets the cost value which identifies a connection as "high-cost" for
connection labeling.
|
void |
setConnectionRepurposeThreshold(Integer threshold)
Sets the connection repurpose threshold for the pool.
|
void |
setConnectionRetrievalInfo(ConnectionRetrievalInfo cri)
Sets the
ConnectionRetrievalInfo for creating the initial
connections (physical connections) in the pool based on the
initialPoolSize property. |
void |
setConnectionWaitTimeout(int waitTimeout)
Sets the amount of time to wait (in seconds) for a used connection to
be released by a client.
|
void |
setHighCostConnectionReuseThreshold(int threshold)
Sets the high-cost connection reuse threshold for connection labeling.
|
void |
setInactiveConnectionTimeout(int inactiveConnectionTimeout)
Sets the inactive connection timeout.
|
void |
setInitialPoolSize(int initialPoolSize)
Sets the initial pool size.
|
void |
setLoginTimeout(int seconds)
Sets the default maximum time in seconds that a driver will wait while attempting
to connect to a database once the driver has been identified.
|
void |
setMaxConnectionReuseCount(int maxConnectionReuseCount)
Sets the maximum connection reuse count property.
|
void |
setMaxConnectionReuseTime(long maxConnectionReuseTime)
Sets the maximum connection reuse time property.
|
void |
setMaxConnectionsPerService(int maxConnectionsPerService)
Sets the maximum number of connections that can be obtained to a particular
service, in a shared pool.
|
void |
setMaxPoolSize(int maxPoolSize)
Sets the maximum number of connections.
|
void |
setMinPoolSize(int minPoolSize)
Sets the minimum number of connections.
|
void |
setName(String name)
Sets the name of the connection pool.
|
void |
setSecondsToTrustIdleConnection(int secondsToTrustIdleConnection)
Sets the time in seconds to trust an idle connection to skip a validation
test.
|
void |
setTimeoutCheckInterval(int timeoutCheckInterval)
Sets the frequency (in seconds) to enforce the timeout properties.
|
void |
setTimeToLiveConnectionTimeout(int timeToLiveConnectionTimeout)
Sets the maximum time (in seconds) a connection may remain in-use.
|
void |
setValidateConnectionOnBorrow(boolean validateConnectionOnBorrow)
Sets whether or not a connection being borrowed should first be
validated.
|
void |
start()
Starts the connection pool.
|
void |
stop()
Stops the connection pool.
|
UniversalPooledConnection borrowConnection(ConnectionRetrievalInfo connectionRetrievalInfo) throws UniversalConnectionPoolException
connectionRetrievalInfo
- Info to use to get the connection.UniversalConnectionPoolException
- if an error occurs getting a
connection.NoAvailableConnectionsException
- if all of the connections are
in use.void returnConnection(UniversalPooledConnection pooledConnection) throws UniversalConnectionPoolException
pooledConnection
- The connection to return back into the
pool.UniversalConnectionPoolException
void closeConnection(UniversalPooledConnection pooledConnection) throws UniversalConnectionPoolException
pooledConnection
- The pooled connection to close.UniversalConnectionPoolException
- if an error occurs closing the
connection.void refresh() throws UniversalConnectionPoolException
UniversalConnectionPoolException
void recycle() throws UniversalConnectionPoolException
UniversalConnectionPoolException
void purge() throws UniversalConnectionPoolException
refresh()
is that the connection pool is left empty with no connections available
after calling purge()
. Some of the connection pool
properties such as minPoolSize
or
initialPoolSize
may not be honored when purging connections
from the pool.
Note that both borrowed and available connections are removed
when this API is called. Any borrowed connections incur an exception
after this API is called. The user is expected to retry and obtain a
new connection from the pool.UniversalConnectionPoolException
void reconfigure(Properties props) throws UniversalConnectionPoolException
props
- Containing new set of pool properties for reconfiguration.UniversalConnectionPoolException
void start() throws UniversalConnectionPoolException
UniversalConnectionPoolException
- If an error occurs during
start.void stop() throws UniversalConnectionPoolException
UniversalConnectionPoolException
String getName()
void setName(String name)
name
- The name of the connection pool.int getInitialPoolSize()
void setInitialPoolSize(int initialPoolSize) throws UniversalConnectionPoolException
initialPoolSize
- the initial pool size.UniversalConnectionPoolException
int getMinPoolSize()
void setMinPoolSize(int minPoolSize) throws UniversalConnectionPoolException
minPoolSize
- The minimum number of connections.UniversalConnectionPoolException
int getMaxPoolSize()
void setMaxPoolSize(int maxPoolSize) throws UniversalConnectionPoolException
maxPoolSize
- The maximum number of connections.UniversalConnectionPoolException
int getInactiveConnectionTimeout()
void setInactiveConnectionTimeout(int inactiveConnectionTimeout) throws UniversalConnectionPoolException
inactiveConnectionTimeout
- The inactive connection timeout
(in seconds).UniversalConnectionPoolException
int getAbandonedConnectionTimeout()
void setAbandonedConnectionTimeout(int abandonedConnectionTimeout) throws UniversalConnectionPoolException
abandonedConnectionTimeout
- The value of how long a connection
has not been used before it is
abandoned (in seconds).UniversalConnectionPoolException
int getConnectionWaitTimeout()
void setConnectionWaitTimeout(int waitTimeout) throws UniversalConnectionPoolException
waitTimeout
- The amount of time to wait.UniversalConnectionPoolException
int getTimeToLiveConnectionTimeout()
void setTimeToLiveConnectionTimeout(int timeToLiveConnectionTimeout) throws UniversalConnectionPoolException
timeToLiveConnectionTimeout
- The maximum time (in seconds) a
used connection may be active.UniversalConnectionPoolException
int getTimeoutCheckInterval()
abandonedConnectionTimeout
,
inactiveConnectionTimeout
, and
timeToLiveConnectionTimeout
.void setTimeoutCheckInterval(int timeoutCheckInterval) throws UniversalConnectionPoolException
timeoutCheckInterval
- The frequency (in seconds) to enforce
the timeout properties.UniversalConnectionPoolException
boolean getValidateConnectionOnBorrow()
true
, connection validity
is performed before returning the connection to the user.void setValidateConnectionOnBorrow(boolean validateConnectionOnBorrow)
validateConnectionOnBorrow
- Whether or not a connection
being borrowed should first be
validated.int getConnectionHarvestTriggerCount()
void setConnectionHarvestTriggerCount(int connectionHarvestTriggerCount) throws UniversalConnectionPoolException
connectionHarvestTriggerCount
- The number of available
connections below which the
connection pool's connection
harvesting occurs.UniversalConnectionPoolException
int getConnectionHarvestMaxCount()
connectionHarvestMaxCount
.void setConnectionHarvestMaxCount(int connectionHarvestMaxCount) throws UniversalConnectionPoolException
connectionHarvestMaxCount
- the maximum number of connections
that may be harvested when the
connection harvesting occurs.UniversalConnectionPoolException
int getAvailableConnectionsCount()
int getBorrowedConnectionsCount()
UniversalConnectionPoolStatistics getStatistics()
UniversalConnectionPoolLifeCycleState getLifeCycleState()
ConnectionRetrievalInfo getConnectionRetrievalInfo()
ConnectionRetrievalInfo
object which contains
user and password information to create the connections.ConnectionRetrievalInfo
object which contains user and
password information to create the connections.void setConnectionRetrievalInfo(ConnectionRetrievalInfo cri)
ConnectionRetrievalInfo
for creating the initial
connections (physical connections) in the pool based on the
initialPoolSize property.cri
- The ConnectionRetrievalInfo
with user and
password for creating the initial connections in the pool.void registerConnectionAffinityCallback(ConnectionAffinityCallback cbk) throws UniversalConnectionPoolException
ConnectionAffinityCallback
objet on the
connection pool.cbk
- The affinity callback object to be registeredUniversalConnectionPoolException
- If callback registration fails.void removeConnectionAffinityCallback() throws UniversalConnectionPoolException
ConnectionAffinityCallback
object registered on
the connection pool.UniversalConnectionPoolException
- If callback removal fails.void registerConnectionLabelingCallback(ConnectionLabelingCallback cbk) throws UniversalConnectionPoolException
ConnectionLabelingCallback
object with this
connection pool.cbk
- The ConnectionLabelingCallback object to be
registered.
UniversalConnectionPoolException
- If there is a callback already
registered with this pool.void removeConnectionLabelingCallback() throws UniversalConnectionPoolException
ConnectionLabelingCallback
object registered
with this connection pool, if any.UniversalConnectionPoolException
- If callback removal fails.long getMaxConnectionReuseTime()
setMaxConnectionReuseTime()
.void setMaxConnectionReuseTime(long maxConnectionReuseTime) throws UniversalConnectionPoolException
maxConnectionReuseTime
- Maximum connection reuse time (in seconds).UniversalConnectionPoolException
int getMaxConnectionReuseCount()
setMaxConnectionReuseCount()
.void setMaxConnectionReuseCount(int maxConnectionReuseCount) throws UniversalConnectionPoolException
maxConnectionReuseCount
- Maximum connection reuse count.UniversalConnectionPoolException
int getSecondsToTrustIdleConnection()
setSecondsToTrustIdleConnection()
.void setSecondsToTrustIdleConnection(int secondsToTrustIdleConnection) throws UniversalConnectionPoolException
setValidateConnectionOnBorrow(boolean)
. When set to any
positive value, a connection validation during the checkout is skipped if
the connection was successfully used and returned to the pool within the
time specified for secondsToTrustIdleConnection. Default value is set to 0
seconds which means that the feature is disabled.secondsToTrustIdleConnection
- The value of how long a connection can be trusted to skip
connectionValidationOnBorrowUniversalConnectionPoolException
int getConnectionLabelingHighCost()
setConnectionLabelingHighCost
void setConnectionLabelingHighCost(int highCost) throws UniversalConnectionPoolException
cost(Properties, Properties)
method in ConnectionLabelingCallback to find a connection in the pool for a
request. When this property is set, connections with a cost value equal to
or greater than the property value are considered "high-cost" connections.
The default value is Integer.MAX_VALUE.highCost
- The cost value that identifies a connection as "high-cost" for
connection labeling.UniversalConnectionPoolException
- If an exception occurs while setting the cost.int getHighCostConnectionReuseThreshold()
setConnectionLabelingHighCost
,
setHighCostConnectionReuseThreshold
void setHighCostConnectionReuseThreshold(int threshold) throws UniversalConnectionPoolException
threshold
- The high-cost connection reuse threshold to set.UniversalConnectionPoolException
- If any exception occurs while setting the threshold.int getMaxConnectionsPerService()
void setMaxConnectionsPerService(int maxConnectionsPerService) throws UniversalConnectionPoolException
maxConnectionsPerService
- The maximum number of connections that can be obtained to a
particular service.UniversalConnectionPoolException
- If any exception occurs while setting the
maxConnectionsPerService value.int getConnectionRepurposeThreshold()
void setConnectionRepurposeThreshold(Integer threshold) throws UniversalConnectionPoolException
threshold
- connection repurpose threshold to set.UniversalConnectionPoolException
- If any exception occurs while setting the threshold.getConnectionRepurposeThreshold
int getLoginTimeout()
void setLoginTimeout(int seconds) throws UniversalConnectionPoolException
seconds
- timeoutUniversalConnectionPoolException
- in case of negative valueboolean isShareable()
Copyright © 2008, 2016, Oracle. All rights reserved.