public class ConnectionPool extends NotificationBroadcasterSupport implements ConnectionPoolMBean, MBeanRegistration
| Modifier and Type | Field and Description |
|---|---|
static String |
FAILED_QUERY_NOTIFICATION |
protected ConcurrentLinkedQueue<NotificationListener> |
listeners
Listeners that are local and interested in our notifications, no need for JMX
|
static String |
NOTIFY_ABANDON |
static String |
NOTIFY_CONNECT |
static String |
NOTIFY_INIT |
protected ConnectionPool |
pool
the connection pool
|
static String |
POOL_EMPTY |
protected AtomicInteger |
sequence
sequence for JMX notifications
|
static String |
SLOW_QUERY_NOTIFICATION |
static String |
SUSPECT_ABANDONED_NOTIFICATION |
static String |
SUSPECT_RETURNED_NOTIFICATION |
PKG_PREFIX| Constructor and Description |
|---|
ConnectionPool(ConnectionPool pool) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(NotificationListener list) |
void |
checkAbandoned() |
void |
checkIdle() |
int |
getAbandonWhenPercentageFull()
Connections that have been abandoned (timed out) wont get closed and reported up unless the number of connections in use are
above the percentage defined by abandonWhenPercentageFull.
|
int |
getActive() |
long |
getBorrowedCount() |
boolean |
getCommitOnReturn() |
String |
getConnectionProperties()
The connection properties that will be sent to the JDBC driver when establishing new connections.
|
long |
getCreatedCount() |
Object |
getDataSource()
Returns a datasource, if one exists that is being used to create connections.
|
String |
getDataSourceJNDI()
Returns the JNDI string configured for data source usage.
|
Properties |
getDbProperties()
Returns the database properties that are passed into the
Driver.connect(String, Properties) method. |
Boolean |
getDefaultAutoCommit()
The default auto-commit state of connections created by this pool.
|
String |
getDefaultCatalog()
If non null, during connection creation the method
Connection.setCatalog(String) will be called with the set value. |
static MBeanNotificationInfo[] |
getDefaultNotificationInfo() |
Boolean |
getDefaultReadOnly()
If non null, during connection creation the method
Connection.setReadOnly(boolean) will be called with the set value. |
int |
getDefaultTransactionIsolation()
Returns the default transaction isolation level.
|
String |
getDriverClassName()
The fully qualified Java class name of the JDBC driver to be used.
|
int |
getIdle() |
int |
getInitialSize()
Returns the number of connections that will be established when the connection pool is started.
|
String |
getInitSQL()
A custom query to be run when a connection is first created.
|
String |
getJdbcInterceptors()
A semicolon separated list of classnames extending
JdbcInterceptor class. |
PoolProperties.InterceptorDefinition[] |
getJdbcInterceptorsAsArray()
Returns the
PoolConfiguration.getJdbcInterceptors() as an array of objects with properties and the classes. |
boolean |
getLogValidationErrors()
Returns true if errors that happen during validation will be logged
|
int |
getMaxActive()
The maximum number of active connections that can be allocated from this pool at the same time.
|
long |
getMaxAge()
Time in milliseconds to keep this connection before reconnecting.
|
int |
getMaxIdle()
The maximum number of connections that should be kept in the idle pool if
PoolConfiguration.isPoolSweeperEnabled() returns false. |
int |
getMaxWait()
The maximum number of milliseconds that the pool will wait (when there are no available connections and the
PoolConfiguration.getMaxActive() has been reached) for a connection to be returned
before throwing an exception. |
int |
getMinEvictableIdleTimeMillis()
The minimum amount of time an object must sit idle in the pool before it is eligible for eviction.
|
int |
getMinIdle()
The minimum number of established connections that should be kept in the pool at all times.
|
String |
getName()
Returns the name of the connection pool.
|
MBeanNotificationInfo[] |
getNotificationInfo() |
int |
getNumActive() |
int |
getNumIdle() |
int |
getNumTestsPerEvictionRun()
Property not used
|
ObjectName |
getObjectName() |
String |
getPassword()
Returns the password used when establishing connections to the database.
|
ConnectionPool |
getPool() |
String |
getPoolName() |
PoolConfiguration |
getPoolProperties() |
boolean |
getPropagateInterruptState()
Returns true if the pool is configured to propagate interrupt state of a thread.
|
long |
getReconnectedCount() |
long |
getReleasedCount() |
long |
getReleasedIdleCount() |
long |
getRemoveAbandonedCount() |
int |
getRemoveAbandonedTimeout()
The time in seconds before a connection can be considered abandoned.
|
long |
getReturnedCount() |
boolean |
getRollbackOnReturn() |
int |
getSize() |
int |
getSuspectTimeout()
Returns the time in seconds to pass before a connection is marked an abandoned suspect.
|
int |
getTimeBetweenEvictionRunsMillis()
The number of milliseconds to sleep between runs of the idle connection validation, abandoned cleaner
and idle pool resizing.
|
String |
getUrl()
The URL used to connect to the database
|
boolean |
getUseDisposableConnectionFacade()
Returns
true if this connection pool is configured to use a connection facade to prevent re-use of connection after
Connection.close() has been invoked |
boolean |
getUseLock()
Return true if a lock should be used when operations are performed on the connection object.
|
String |
getUsername()
Returns the username used to establish the connection with
|
boolean |
getUseStatementFacade()
Returns
true if this connection pool is configured to wrap statements in order
to enable equals() and hashCode() methods to be called on the closed statements if any
statement proxy is set. |
long |
getValidationInterval()
avoid excess validation, only run validation at most at this frequency - time in milliseconds.
|
String |
getValidationQuery()
The SQL query that will be used to validate connections from this
pool before returning them to the caller or pool.
|
int |
getValidationQueryTimeout()
The timeout in seconds before a connection validation queries fail.
|
Validator |
getValidator() |
String |
getValidatorClassName()
Return the name of the optional validator class - may be null.
|
int |
getWaitCount() |
boolean |
isAccessToUnderlyingConnectionAllowed()
Property not used.
|
boolean |
isAlternateUsernameAllowed()
Returns true if the call
getConnection(username,password) is
allowed. |
Boolean |
isDefaultAutoCommit()
The default auto-commit state of connections created by this pool.
|
Boolean |
isDefaultReadOnly()
If non null, during connection creation the method
Connection.setReadOnly(boolean) will be called with the set value. |
boolean |
isFairQueue()
Returns
true if a fair queue is being used by the connection pool |
boolean |
isIgnoreExceptionOnPreLoad() |
boolean |
isJmxEnabled()
If set to true, the connection pool creates a
ConnectionPoolMBean object
that can be registered with JMX to receive notifications and state about the pool. |
boolean |
isLogAbandoned()
boolean flag to set if stack traces should be logged for application code which abandoned a Connection.
|
boolean |
isPoolSweeperEnabled()
Returns true if the pool sweeper is enabled for the connection pool.
|
boolean |
isRemoveAbandoned()
boolean flag to remove abandoned connections if they exceed the removeAbandonedTimeout.
|
boolean |
isTestOnBorrow()
The indication of whether objects will be validated before being borrowed from the pool.
|
boolean |
isTestOnConnect()
Returns true if we should run the validation query when connecting to the database for the first time on a connection.
|
boolean |
isTestOnReturn()
The indication of whether objects will be validated after being returned to the pool.
|
boolean |
isTestWhileIdle()
Set to true if query validation should take place while the connection is idle.
|
boolean |
isUseEquals()
Set to true if you wish the
ProxyConnection class to use String.equals instead of
== when comparing method names. |
boolean |
notify(String type,
String message)
Return true if the notification was sent successfully, false otherwise.
|
void |
postDeregister() |
void |
postRegister(Boolean registrationDone) |
void |
preDeregister() |
ObjectName |
preRegister(MBeanServer server,
ObjectName name) |
void |
purge()
Purges all connections in the pool.
|
void |
purgeOnReturn()
Purges connections when they are returned from the pool.
|
boolean |
removeListener(NotificationListener list) |
void |
resetStats()
reset the statistics of this pool.
|
void |
setAbandonWhenPercentageFull(int percentage)
Connections that have been abandoned (timed out) wont get closed and reported up unless the number of connections in use are
above the percentage defined by abandonWhenPercentageFull.
|
void |
setAccessToUnderlyingConnectionAllowed(boolean accessToUnderlyingConnectionAllowed)
No-op
|
void |
setAlternateUsernameAllowed(boolean alternateUsernameAllowed)
Set to true if the call
getConnection(username,password) is
allowed and honored.. |
void |
setCommitOnReturn(boolean commitOnReturn)
Set to true if you want the connection pool to commit any pending transaction when a connection is returned.
|
void |
setConnectionProperties(String connectionProperties)
The properties that will be passed into
Driver.connect(String, Properties) method. |
void |
setDataSource(Object ds)
Injects a datasource that will be used to retrieve/create connections.
|
void |
setDataSourceJNDI(String jndiDS)
Configure the connection pool to use a DataSource according to
PoolConfiguration.setDataSource(Object)
But instead of injecting the object, specify the JNDI location. |
void |
setDbProperties(Properties dbProperties)
Overrides the database properties passed into the
Driver.connect(String, Properties) method. |
void |
setDefaultAutoCommit(Boolean defaultAutoCommit)
The default auto-commit state of connections created by this pool.
|
void |
setDefaultCatalog(String defaultCatalog)
If non null, during connection creation the method
Connection.setCatalog(String) will be called with the set value. |
void |
setDefaultReadOnly(Boolean defaultReadOnly)
If non null, during connection creation the method
Connection.setReadOnly(boolean) will be called with the set value. |
void |
setDefaultTransactionIsolation(int defaultTransactionIsolation)
If set to
DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION the method
Connection.setTransactionIsolation(int) will not be called during connection creation. |
void |
setDriverClassName(String driverClassName)
The fully qualified Java class name of the JDBC driver to be used.
|
void |
setFairQueue(boolean fairQueue)
Set to true if you wish that calls to getConnection
should be treated fairly in a true FIFO fashion.
|
void |
setIgnoreExceptionOnPreLoad(boolean ignoreExceptionOnPreLoad)
Set to true if you want to ignore error of connection creation while initializing the pool.
|
void |
setInitialSize(int initialSize)
Set the number of connections that will be established when the connection pool is started.
|
void |
setInitSQL(String initSQL)
A custom query to be run when a connection is first created.
|
void |
setJdbcInterceptors(String jdbcInterceptors)
A semicolon separated list of classnames extending
JdbcInterceptor class. |
void |
setJmxEnabled(boolean jmxEnabled)
If set to true, the connection pool creates a
ConnectionPoolMBean object
that can be registered with JMX to receive notifications and state about the pool. |
void |
setLogAbandoned(boolean logAbandoned)
boolean flag to set if stack traces should be logged for application code which abandoned a Connection.
|
void |
setLogValidationErrors(boolean logValidationErrors)
Set to true if you wish that errors from validation should be logged as error messages.
|
void |
setMaxActive(int maxActive)
The maximum number of active connections that can be allocated from this pool at the same time.
|
void |
setMaxAge(long maxAge)
Time in milliseconds to keep this connection before reconnecting.
|
void |
setMaxIdle(int maxIdle)
The maximum number of connections that should be kept in the idle pool if
PoolConfiguration.isPoolSweeperEnabled() returns false. |
void |
setMaxWait(int maxWait)
The maximum number of milliseconds that the pool will wait (when there are no available connections and the
PoolConfiguration.getMaxActive() has been reached) for a connection to be returned
before throwing an exception. |
void |
setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis)
The minimum amount of time an object must sit idle in the pool before it is eligible for eviction.
|
void |
setMinIdle(int minIdle)
The minimum number of established connections that should be kept in the pool at all times.
|
void |
setName(String name)
Sets the name of the connection pool
|
void |
setNumTestsPerEvictionRun(int numTestsPerEvictionRun)
Property not used
|
void |
setPassword(String password)
Sets the password to establish the connection with.
|
void |
setPropagateInterruptState(boolean propagateInterruptState)
Configure the pool to propagate interrupt state for interrupted threads waiting for a connection
A thread waiting for a connection, can have its wait interrupted, and by default
will clear the interrupt flag and throw a
PoolExhaustedException
If set to true, this behavior will change, while the PoolExhaustedException is still thrown, the threads interrupted state is still set. |
void |
setRemoveAbandoned(boolean removeAbandoned)
boolean flag to remove abandoned connections if they exceed the removeAbandonedTimeout.
|
void |
setRemoveAbandonedTimeout(int removeAbandonedTimeout)
The time in seconds before a connection can be considered abandoned.
|
void |
setRollbackOnReturn(boolean rollbackOnReturn)
Set to true if you want the connection pool to rollback any pending transaction when a connection is returned.
|
void |
setSuspectTimeout(int seconds)
Similar to
PoolConfiguration.setRemoveAbandonedTimeout(int) but instead of treating the connection
as abandoned, and potentially closing the connection, this simply logs the warning if
PoolConfiguration.isLogAbandoned() returns true. |
void |
setTestOnBorrow(boolean testOnBorrow)
The indication of whether objects will be validated before being borrowed from the pool.
|
void |
setTestOnConnect(boolean testOnConnect)
Set to true if we should run the validation query when connecting to the database for the first time on a connection.
|
void |
setTestOnReturn(boolean testOnReturn)
The indication of whether objects will be validated after being returned to the pool.
|
void |
setTestWhileIdle(boolean testWhileIdle)
Set to true if query validation should take place while the connection is idle.
|
void |
setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis)
The number of milliseconds to sleep between runs of the idle connection validation, abandoned cleaner
and idle pool resizing.
|
void |
setUrl(String url)
Sets the URL used to connect to the database
|
void |
setUseDisposableConnectionFacade(boolean useDisposableConnectionFacade)
If set to
true, the connection will be wrapped with facade that will disallow the connection to be used after
Connection.close() is called. |
void |
setUseEquals(boolean useEquals)
Set to true if you wish the
ProxyConnection class to use String.equals instead of
== when comparing method names. |
void |
setUseLock(boolean useLock)
Set to true if a lock should be used when operations are performed on the connection object.
|
void |
setUsername(String username)
Sets the username used to establish the connection with
It will also be a property called 'user' in the database properties.
|
void |
setUseStatementFacade(boolean useStatementFacade)
Set this to true if you wish to wrap statements in order to enable equals() and hashCode()
methods to be called on the closed statements if any statement proxy is set.
|
void |
setValidationInterval(long validationInterval)
avoid excess validation, only run validation at most at this frequency - time in milliseconds.
|
void |
setValidationQuery(String validationQuery)
The SQL query that will be used to validate connections from this
pool before returning them to the caller or pool.
|
void |
setValidationQueryTimeout(int validationQueryTimeout)
The timeout in seconds before a connection validation queries fail.
|
void |
setValidator(Validator validator)
Sets the validator object
If this is a non null object, it will be used as a validator instead of the validationQuery
If this is null, remove the usage of the validator.
|
void |
setValidatorClassName(String className)
Set the name for an optional validator class which will be used in place of test queries.
|
void |
testIdle() |
addNotificationListener, handleNotification, removeNotificationListener, removeNotificationListener, sendNotificationprotected ConnectionPool pool
protected AtomicInteger sequence
protected ConcurrentLinkedQueue<NotificationListener> listeners
public static final String NOTIFY_INIT
public static final String NOTIFY_CONNECT
public static final String NOTIFY_ABANDON
public static final String SLOW_QUERY_NOTIFICATION
public static final String FAILED_QUERY_NOTIFICATION
public static final String SUSPECT_ABANDONED_NOTIFICATION
public static final String POOL_EMPTY
public static final String SUSPECT_RETURNED_NOTIFICATION
public ConnectionPool(ConnectionPool pool)
public ConnectionPool getPool()
public PoolConfiguration getPoolProperties()
public ObjectName getObjectName()
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
preRegister in interface MBeanRegistrationExceptionpublic void postRegister(Boolean registrationDone)
postRegister in interface MBeanRegistrationpublic void preDeregister()
throws Exception
preDeregister in interface MBeanRegistrationExceptionpublic void postDeregister()
postDeregister in interface MBeanRegistrationpublic MBeanNotificationInfo[] getNotificationInfo()
getNotificationInfo in interface NotificationBroadcastergetNotificationInfo in class NotificationBroadcasterSupportpublic static MBeanNotificationInfo[] getDefaultNotificationInfo()
public boolean notify(String type, String message)
type - The notification typemessage - The messagepublic void addListener(NotificationListener list)
public boolean removeListener(NotificationListener list)
public int getSize()
getSize in interface ConnectionPoolMBeanpublic int getIdle()
getIdle in interface ConnectionPoolMBeanpublic int getActive()
getActive in interface ConnectionPoolMBeanpublic int getNumIdle()
getNumIdle in interface ConnectionPoolMBeanpublic int getNumActive()
getNumActive in interface ConnectionPoolMBeanpublic int getWaitCount()
getWaitCount in interface ConnectionPoolMBeanpublic long getBorrowedCount()
getBorrowedCount in interface ConnectionPoolMBeanpublic long getReturnedCount()
getReturnedCount in interface ConnectionPoolMBeanpublic long getCreatedCount()
getCreatedCount in interface ConnectionPoolMBeanpublic long getReleasedCount()
getReleasedCount in interface ConnectionPoolMBeanpublic long getReconnectedCount()
getReconnectedCount in interface ConnectionPoolMBeanpublic long getRemoveAbandonedCount()
getRemoveAbandonedCount in interface ConnectionPoolMBeanpublic long getReleasedIdleCount()
getReleasedIdleCount in interface ConnectionPoolMBeanpublic void checkIdle()
checkIdle in interface ConnectionPoolMBeanpublic void checkAbandoned()
checkAbandoned in interface ConnectionPoolMBeanpublic void testIdle()
testIdle in interface ConnectionPoolMBeanpublic void resetStats()
ConnectionPoolMBeanresetStats in interface ConnectionPoolMBeanpublic String getConnectionProperties()
PoolConfigurationgetConnectionProperties in interface PoolConfigurationpublic Properties getDbProperties()
PoolConfigurationDriver.connect(String, Properties) method.getDbProperties in interface PoolConfigurationDriver.connect(String, Properties) method.public String getDefaultCatalog()
PoolConfigurationConnection.setCatalog(String) will be called with the set value.getDefaultCatalog in interface PoolConfigurationpublic int getDefaultTransactionIsolation()
PoolConfigurationDataSourceFactory.UNKNOWN_TRANSACTIONISOLATION the method
Connection.setTransactionIsolation(int) will not be called during connection creation.getDefaultTransactionIsolation in interface PoolConfigurationDataSourceFactory.UNKNOWN_TRANSACTIONISOLATION if not set.public String getDriverClassName()
PoolConfigurationgetDriverClassName in interface PoolConfigurationpublic int getInitialSize()
PoolConfigurationgetInitialSize in interface PoolConfigurationpublic String getInitSQL()
PoolConfigurationgetInitSQL in interface PoolConfigurationpublic String getJdbcInterceptors()
PoolConfigurationJdbcInterceptor class.
These interceptors will be inserted as an interceptor into the chain of operations on a java.sql.Connection object.
Example interceptors are StatementFinalizer to close all
used statements during the session.
ResetAbandonedTimer resets the timer upon every operation
on the connection or a statement.
ConnectionState caches the auto commit, read only and catalog settings to avoid round trips to the DB.
The default value is null.getJdbcInterceptors in interface PoolConfigurationpublic int getMaxActive()
PoolConfigurationgetMaxActive in interface PoolConfigurationpublic int getMaxIdle()
PoolConfigurationPoolConfiguration.isPoolSweeperEnabled() returns false.
If the If PoolConfiguration.isPoolSweeperEnabled() returns true, then the idle pool can grow up to PoolConfiguration.getMaxActive()
and will be shrunk according to PoolConfiguration.getMinEvictableIdleTimeMillis() setting.
Default value is maxActive:100getMaxIdle in interface PoolConfigurationpublic int getMaxWait()
PoolConfigurationPoolConfiguration.getMaxActive() has been reached) for a connection to be returned
before throwing an exception. Default value is 30000 (30 seconds)getMaxWait in interface PoolConfigurationpublic int getMinEvictableIdleTimeMillis()
PoolConfigurationgetMinEvictableIdleTimeMillis in interface PoolConfigurationpublic int getMinIdle()
PoolConfigurationPoolConfiguration.getInitialSize() (also see PoolConfiguration.setTestWhileIdle(boolean)
The idle pool will not shrink below this value during an eviction run, hence the number of actual connections
can be between PoolConfiguration.getMinIdle() and somewhere between PoolConfiguration.getMaxIdle() and PoolConfiguration.getMaxActive()getMinIdle in interface PoolConfigurationpublic long getMaxAge()
PoolConfigurationPoolConfiguration.getTimeBetweenEvictionRunsMillis() returns a value greater than 0.
The default value is 0, which implies that connections will be left open and no
age checks will be done.
This is a useful setting for database sessions that leak memory as it ensures that the session
will have a finite life span.getMaxAge in interface PoolConfigurationpublic String getName()
PoolConfigurationgetName in interface PoolConfigurationpublic int getNumTestsPerEvictionRun()
PoolConfigurationgetNumTestsPerEvictionRun in interface PoolConfigurationpublic String getPassword()
PoolConfigurationgetPassword in interface PoolConfigurationpublic int getRemoveAbandonedTimeout()
PoolConfigurationgetRemoveAbandonedTimeout in interface PoolConfigurationResetAbandonedTimerpublic int getTimeBetweenEvictionRunsMillis()
PoolConfigurationgetTimeBetweenEvictionRunsMillis in interface PoolConfigurationpublic String getUrl()
PoolConfigurationgetUrl in interface PoolConfigurationDriver.connect(String, Properties)public String getUsername()
PoolConfigurationgetUsername in interface PoolConfigurationpublic long getValidationInterval()
PoolConfigurationgetValidationInterval in interface PoolConfigurationpublic String getValidationQuery()
PoolConfigurationgetValidationQuery in interface PoolConfigurationpublic int getValidationQueryTimeout()
PoolConfigurationgetValidationQueryTimeout in interface PoolConfigurationpublic String getValidatorClassName()
getValidatorClassName in interface PoolConfigurationpublic Validator getValidator()
getValidator in interface PoolConfigurationpublic boolean isAccessToUnderlyingConnectionAllowed()
PoolConfigurationDataSource interface
or call getConnection through reflection or cast the object as PooledConnectionisAccessToUnderlyingConnectionAllowed in interface PoolConfigurationtruepublic Boolean isDefaultAutoCommit()
PoolConfigurationConnection.setAutoCommit(boolean) method will not be called.)isDefaultAutoCommit in interface PoolConfigurationpublic Boolean isDefaultReadOnly()
PoolConfigurationConnection.setReadOnly(boolean) will be called with the set value.isDefaultReadOnly in interface PoolConfigurationpublic boolean isLogAbandoned()
PoolConfigurationisLogAbandoned in interface PoolConfigurationpublic boolean isPoolSweeperEnabled()
PoolConfiguration
boolean result = getTimeBetweenEvictionRunsMillis()>0;
result = result && (isRemoveAbandoned() && getRemoveAbandonedTimeout()>0);
result = result || (isTestWhileIdle() && getValidationQuery()!=null);
return result;
isPoolSweeperEnabled in interface PoolConfigurationpublic boolean isRemoveAbandoned()
PoolConfigurationPoolConfiguration.getRemoveAbandonedTimeout() and the condition for
PoolConfiguration.getAbandonWhenPercentageFull() is met.
Setting this to true can recover db connections from applications that fail to close a connection.
See also PoolConfiguration.isLogAbandoned() The default value is false.isRemoveAbandoned in interface PoolConfigurationpublic int getAbandonWhenPercentageFull()
PoolConfigurationgetAbandonWhenPercentageFull in interface PoolConfigurationpublic boolean isTestOnBorrow()
PoolConfigurationPoolConfiguration.setValidationInterval(long)isTestOnBorrow in interface PoolConfigurationPoolConfiguration.getValidationInterval()public boolean isTestOnConnect()
PoolConfigurationisTestOnConnect in interface PoolConfigurationpublic boolean isTestOnReturn()
PoolConfigurationPoolConfiguration.setValidationInterval(long)isTestOnReturn in interface PoolConfigurationPoolConfiguration.getValidationInterval()public boolean isTestWhileIdle()
PoolConfigurationisTestWhileIdle in interface PoolConfigurationPoolConfiguration.setTimeBetweenEvictionRunsMillis(int)public Boolean getDefaultAutoCommit()
PoolConfigurationConnection.setAutoCommit(boolean) method will not be called.)getDefaultAutoCommit in interface PoolConfigurationpublic Boolean getDefaultReadOnly()
PoolConfigurationConnection.setReadOnly(boolean) will be called with the set value.getDefaultReadOnly in interface PoolConfigurationpublic PoolProperties.InterceptorDefinition[] getJdbcInterceptorsAsArray()
PoolConfigurationPoolConfiguration.getJdbcInterceptors() as an array of objects with properties and the classes.getJdbcInterceptorsAsArray in interface PoolConfigurationpublic boolean getUseLock()
PoolConfigurationgetUseLock in interface PoolConfigurationpublic boolean isFairQueue()
PoolConfigurationtrue if a fair queue is being used by the connection poolisFairQueue in interface PoolConfigurationtrue if a fair waiting queue is being usedpublic boolean isJmxEnabled()
PoolConfigurationConnectionPoolMBean object
that can be registered with JMX to receive notifications and state about the pool.
The ConnectionPool object doesn't register itself, as there is no way to keep a static non changing ObjectName across JVM restarts.isJmxEnabled in interface PoolConfigurationpublic boolean isUseEquals()
PoolConfigurationProxyConnection class to use String.equals instead of
== when comparing method names.
This property does not apply to added interceptors as those are configured individually.
The default value is false.isUseEquals in interface PoolConfigurationString.equals(Object) instead of == when comparing method names on Connection methodspublic void setAbandonWhenPercentageFull(int percentage)
PoolConfigurationsetAbandonWhenPercentageFull in interface PoolConfigurationpercentage - a value between 0 and 100 to indicate when connections that have been abandoned/timed out are considered abandonedpublic void setAccessToUnderlyingConnectionAllowed(boolean accessToUnderlyingConnectionAllowed)
PoolConfigurationsetAccessToUnderlyingConnectionAllowed in interface PoolConfigurationaccessToUnderlyingConnectionAllowed - parameter ignoredpublic void setDbProperties(Properties dbProperties)
PoolConfigurationDriver.connect(String, Properties) method.setDbProperties in interface PoolConfigurationdbProperties - The database propertiespublic void setDefaultReadOnly(Boolean defaultReadOnly)
PoolConfigurationConnection.setReadOnly(boolean) will be called with the set value.setDefaultReadOnly in interface PoolConfigurationdefaultReadOnly - null if not set and accepting the driver default.public void setMaxAge(long maxAge)
PoolConfigurationPoolConfiguration.getTimeBetweenEvictionRunsMillis() returns a value greater than 0.
The default value is 0, which implies that connections will be left open and no
age checks will be done.
This is a useful setting for database sessions that leak memory as it ensures that the session
will have a finite life span.setMaxAge in interface PoolConfigurationmaxAge - the time in milliseconds a connection will be open for when usedpublic void setName(String name)
PoolConfigurationsetName in interface PoolConfigurationname - the name of the pool, should be unique in a runtime JVMpublic String getPoolName()
getPoolName in interface PoolConfigurationPoolConfiguration.getName()public void setConnectionProperties(String connectionProperties)
PoolConfigurationDriver.connect(String, Properties) method.
Username and password do not need to be stored here, they will be passed into the properties right before the connection is established.setConnectionProperties in interface PoolConfigurationconnectionProperties - properties - Format of the string is [propertyName=property;]*
Example: prop1=value1;prop2=value2public void setDefaultAutoCommit(Boolean defaultAutoCommit)
PoolConfigurationConnection.setAutoCommit(boolean) method will not be called.)setDefaultAutoCommit in interface PoolConfigurationdefaultAutoCommit - default auto commit setting, null is Driver default.public void setDefaultCatalog(String defaultCatalog)
PoolConfigurationConnection.setCatalog(String) will be called with the set value.setDefaultCatalog in interface PoolConfigurationdefaultCatalog - null if not set and accepting the driver default.public void setDefaultTransactionIsolation(int defaultTransactionIsolation)
PoolConfigurationDataSourceFactory.UNKNOWN_TRANSACTIONISOLATION the method
Connection.setTransactionIsolation(int) will not be called during connection creation. Otherwise the method
will be called with the isolation level set by this property.setDefaultTransactionIsolation in interface PoolConfigurationdefaultTransactionIsolation - a value of Connection.TRANSACTION_NONE, Connection.TRANSACTION_READ_COMMITTED,
Connection.TRANSACTION_READ_UNCOMMITTED, Connection.TRANSACTION_REPEATABLE_READ,
Connection.TRANSACTION_SERIALIZABLE or DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION
The last value will not be set on the connection.public void setDriverClassName(String driverClassName)
PoolConfigurationsetDriverClassName in interface PoolConfigurationdriverClassName - a fully qualified Java class name of a Driver implementation.public void setFairQueue(boolean fairQueue)
PoolConfigurationFairBlockingQueue implementation for the list of the idle connections.
The default value is true.
This flag is required when you want to use asynchronous connection retrieval.setFairQueue in interface PoolConfigurationfairQueue - true to use a fair queuepublic void setInitialSize(int initialSize)
PoolConfigurationPoolConfiguration.setMaxActive(int) it will automatically be lowered.setInitialSize in interface PoolConfigurationinitialSize - the number of connections to be established.public void setInitSQL(String initSQL)
PoolConfigurationsetInitSQL in interface PoolConfigurationinitSQL - the init SQL used to run against the DB or null if no query should be executedpublic void setJdbcInterceptors(String jdbcInterceptors)
PoolConfigurationJdbcInterceptor class.
These interceptors will be inserted as an interceptor into the chain of operations on a java.sql.Connection object.
Example interceptors are StatementFinalizer to close all
used statements during the session.
ResetAbandonedTimer resets the timer upon every operation
on the connection or a statement.
ConnectionState caches the auto commit, read only and catalog settings to avoid round trips to the DB.
The default value is null.setJdbcInterceptors in interface PoolConfigurationjdbcInterceptors - the interceptors that are used for connections.
Example format: 'ConnectionState(useEquals=true,fast=yes);ResetAbandonedTimer'public void setJmxEnabled(boolean jmxEnabled)
PoolConfigurationConnectionPoolMBean object
that can be registered with JMX to receive notifications and state about the pool.
The ConnectionPool object doesn't register itself, as there is no way to keep a static non changing ObjectName across JVM restarts.setJmxEnabled in interface PoolConfigurationjmxEnabled - set to to if the mbean object should be created upon startup.public void setLogAbandoned(boolean logAbandoned)
PoolConfigurationsetLogAbandoned in interface PoolConfigurationlogAbandoned - set to true if stack traces should be recorded when DataSourceProxy.getConnection() is called.public void setMaxActive(int maxActive)
PoolConfigurationsetMaxActive in interface PoolConfigurationmaxActive - hard limit for number of managed connections by this poolpublic void setMaxIdle(int maxIdle)
PoolConfigurationPoolConfiguration.isPoolSweeperEnabled() returns false.
If the If PoolConfiguration.isPoolSweeperEnabled() returns true, then the idle pool can grow up to PoolConfiguration.getMaxActive()
and will be shrunk according to PoolConfiguration.getMinEvictableIdleTimeMillis() setting.
Default value is maxActive:100setMaxIdle in interface PoolConfigurationmaxIdle - the maximum size of the idle poolpublic void setMaxWait(int maxWait)
PoolConfigurationPoolConfiguration.getMaxActive() has been reached) for a connection to be returned
before throwing an exception. Default value is 30000 (30 seconds)setMaxWait in interface PoolConfigurationmaxWait - the maximum number of milliseconds to wait.public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis)
PoolConfigurationsetMinEvictableIdleTimeMillis in interface PoolConfigurationminEvictableIdleTimeMillis - the number of milliseconds a connection must be idle to be eligible for eviction.public void setMinIdle(int minIdle)
PoolConfigurationPoolConfiguration.getInitialSize() (also see PoolConfiguration.setTestWhileIdle(boolean)
The idle pool will not shrink below this value during an eviction run, hence the number of actual connections
can be between PoolConfiguration.getMinIdle() and somewhere between PoolConfiguration.getMaxIdle() and PoolConfiguration.getMaxActive()setMinIdle in interface PoolConfigurationminIdle - the minimum number of idle or established connectionspublic void setNumTestsPerEvictionRun(int numTestsPerEvictionRun)
PoolConfigurationsetNumTestsPerEvictionRun in interface PoolConfigurationnumTestsPerEvictionRun - parameter ignored.public void setPassword(String password)
PoolConfigurationsetPassword in interface PoolConfigurationpassword - The passwordPoolConfiguration.getDbProperties()public void setRemoveAbandoned(boolean removeAbandoned)
PoolConfigurationPoolConfiguration.getRemoveAbandonedTimeout() and the condition for
PoolConfiguration.getAbandonWhenPercentageFull() is met.
Setting this to true can recover db connections from applications that fail to close a connection.
See also PoolConfiguration.isLogAbandoned() The default value is false.setRemoveAbandoned in interface PoolConfigurationremoveAbandoned - set to true if abandoned connections can be closed and expelled out of the poolpublic void setRemoveAbandonedTimeout(int removeAbandonedTimeout)
PoolConfigurationsetRemoveAbandonedTimeout in interface PoolConfigurationremoveAbandonedTimeout - the time in seconds before a used connection can be considered abandonedResetAbandonedTimerpublic void setTestOnBorrow(boolean testOnBorrow)
PoolConfigurationPoolConfiguration.setValidationInterval(long)setTestOnBorrow in interface PoolConfigurationtestOnBorrow - set to true if validation should take place before a connection is handed out to the applicationPoolConfiguration.getValidationInterval()public void setTestOnConnect(boolean testOnConnect)
PoolConfigurationPoolConfiguration.setInitSQL(String) will override this setting, as the init SQL will be used instead of the validation querysetTestOnConnect in interface PoolConfigurationtestOnConnect - set to true if we should run the validation query upon connectpublic void setTestOnReturn(boolean testOnReturn)
PoolConfigurationPoolConfiguration.setValidationInterval(long)setTestOnReturn in interface PoolConfigurationtestOnReturn - true if validation should take place after a connection is returned to the poolPoolConfiguration.getValidationInterval()public void setTestWhileIdle(boolean testWhileIdle)
PoolConfigurationsetTestWhileIdle in interface PoolConfigurationtestWhileIdle - true if validation should take place during idle checksPoolConfiguration.setTimeBetweenEvictionRunsMillis(int)public void setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis)
PoolConfigurationsetTimeBetweenEvictionRunsMillis in interface PoolConfigurationtimeBetweenEvictionRunsMillis - the sleep time in between validations in millisecondspublic void setUrl(String url)
PoolConfigurationsetUrl in interface PoolConfigurationurl - the configured URL for this connection poolDriver.connect(String, Properties)public void setUseEquals(boolean useEquals)
PoolConfigurationProxyConnection class to use String.equals instead of
== when comparing method names.
This property does not apply to added interceptors as those are configured individually.
The default value is false.setUseEquals in interface PoolConfigurationuseEquals - set to true if the pool should use String.equals(Object) instead of ==
when comparing method names on Connection methodspublic void setUseLock(boolean useLock)
PoolConfigurationsetUseLock in interface PoolConfigurationuseLock - set to true if a lock should be used on connection operationspublic void setUsername(String username)
PoolConfigurationsetUsername in interface PoolConfigurationusername - The user namePoolConfiguration.getDbProperties()public void setValidationInterval(long validationInterval)
PoolConfigurationsetValidationInterval in interface PoolConfigurationvalidationInterval - the validation interval in millisecondspublic void setValidationQuery(String validationQuery)
PoolConfigurationsetValidationQuery in interface PoolConfigurationvalidationQuery - the query used for validation or null if no validation is performedpublic void setValidationQueryTimeout(int validationQueryTimeout)
PoolConfigurationsetValidationQueryTimeout in interface PoolConfigurationvalidationQueryTimeout - The timeout valuepublic void setValidatorClassName(String className)
setValidatorClassName in interface PoolConfigurationclassName - the name of the optional validator classpublic int getSuspectTimeout()
getSuspectTimeout in interface PoolConfigurationpublic void setSuspectTimeout(int seconds)
PoolConfiguration.setRemoveAbandonedTimeout(int) but instead of treating the connection
as abandoned, and potentially closing the connection, this simply logs the warning if
PoolConfiguration.isLogAbandoned() returns true. If this value is equal or less than 0, no suspect
checking will be performed. Suspect checking only takes place if the timeout value is larger than 0 and
the connection was not abandoned or if abandon check is disabled. If a connection is suspect a WARN message gets
logged and a JMX notification gets sent once.setSuspectTimeout in interface PoolConfigurationseconds - - the amount of time in seconds that has to pass before a connection is marked suspect.public void setDataSource(Object ds)
PoolConfiguration.getUrl() and PoolConfiguration.getDriverClassName() methods are ignored
and not used by the pool. If the PoolConfiguration.getUsername() and PoolConfiguration.getPassword()
values are set, the method DataSource.getConnection(String, String) method will be called instead of the
DataSource.getConnection() method.
If the data source implements XADataSource the methods
XADataSource.getXAConnection() and XADataSource.getXAConnection(String,String)
will be invoked.setDataSource in interface PoolConfigurationds - the DataSource to be used for creating connections to be pooled.public Object getDataSource()
DrivergetDataSource in interface PoolConfigurationDataSource to be used for creating connections to be pooled or null if a Driver is used.public void setDataSourceJNDI(String jndiDS)
PoolConfiguration.setDataSource(Object)
But instead of injecting the object, specify the JNDI location.
After a successful JNDI look, the PoolConfiguration.getDataSource() will not return null.setDataSourceJNDI in interface PoolConfigurationjndiDS - -the JNDI string @TODO specify the rules here.public String getDataSourceJNDI()
getDataSourceJNDI in interface PoolConfigurationpublic boolean isAlternateUsernameAllowed()
getConnection(username,password) is
allowed. This is used for when the pool is used by an application accessing multiple schemas.
There is a performance impact turning this option on.isAlternateUsernameAllowed in interface PoolConfigurationgetConnection(username,password) is honored, false if it is ignored.public void setAlternateUsernameAllowed(boolean alternateUsernameAllowed)
getConnection(username,password) is
allowed and honored.. This is used for when the pool is used by an application accessing multiple schemas.
There is a performance impact turning this option on, even when not used due to username checks.setAlternateUsernameAllowed in interface PoolConfigurationalternateUsernameAllowed - - set true if getConnection(username,password) is honored,
false if it is to be ignored.public void setValidator(Validator validator)
setValidator in interface PoolConfigurationvalidator - The validator objectpublic void setCommitOnReturn(boolean commitOnReturn)
PoolConfiguration.getDefaultAutoCommit() returns falsesetCommitOnReturn in interface PoolConfigurationcommitOnReturn - set to true if the pool should call Connection.commit() when a connection is returned to the pool.
Default is falsepublic boolean getCommitOnReturn()
getCommitOnReturn in interface PoolConfigurationtrue if the pool should commit when a connection is returned to itPoolConfiguration.setCommitOnReturn(boolean)public void setRollbackOnReturn(boolean rollbackOnReturn)
PoolConfiguration.getDefaultAutoCommit() returns falsesetRollbackOnReturn in interface PoolConfigurationrollbackOnReturn - set to true if the pool should call Connection.rollback() when a connection is returned to the pool.
Default is falsepublic boolean getRollbackOnReturn()
getRollbackOnReturn in interface PoolConfigurationtrue if the pool should rollback when a connection is returned to itPoolConfiguration.setRollbackOnReturn(boolean)public void setUseDisposableConnectionFacade(boolean useDisposableConnectionFacade)
true, the connection will be wrapped with facade that will disallow the connection to be used after
Connection.close() is called. If set to true, after Connection.close() all calls except
Connection.close() and Connection.isClosed() will throw an exception.setUseDisposableConnectionFacade in interface PoolConfigurationuseDisposableConnectionFacade - true to use a facadepublic boolean getUseDisposableConnectionFacade()
true if this connection pool is configured to use a connection facade to prevent re-use of connection after
Connection.close() has been invokedgetUseDisposableConnectionFacade in interface PoolConfigurationtrue if Connection.close() has been invoked.public void setLogValidationErrors(boolean logValidationErrors)
setLogValidationErrors in interface PoolConfigurationlogValidationErrors - set to true to log validation errorspublic boolean getLogValidationErrors()
getLogValidationErrors in interface PoolConfigurationpublic boolean getPropagateInterruptState()
PoolExhaustedExceptiongetPropagateInterruptState in interface PoolConfigurationpublic void setPropagateInterruptState(boolean propagateInterruptState)
PoolExhaustedException
If set to true, this behavior will change, while the PoolExhaustedException is still thrown, the threads interrupted state is still set.setPropagateInterruptState in interface PoolConfigurationpropagateInterruptState - - set to true to not clear, but propagate, a threads interrupted state.public boolean isIgnoreExceptionOnPreLoad()
isIgnoreExceptionOnPreLoad in interface PoolConfigurationtrue to ignore exceptionsPoolConfiguration.setIgnoreExceptionOnPreLoad(boolean)public void setIgnoreExceptionOnPreLoad(boolean ignoreExceptionOnPreLoad)
setIgnoreExceptionOnPreLoad in interface PoolConfigurationignoreExceptionOnPreLoad - set to true if you want to ignore error of connection creation while initializing the pool.public boolean getUseStatementFacade()
true if this connection pool is configured to wrap statements in order
to enable equals() and hashCode() methods to be called on the closed statements if any
statement proxy is set.getUseStatementFacade in interface PoolConfigurationtrue if the statements are wrappedpublic void setUseStatementFacade(boolean useStatementFacade)
setUseStatementFacade in interface PoolConfigurationuseStatementFacade - set to true to wrap statementspublic void purge()
ConnectionPoolMBean.purgeOnReturn()purge in interface ConnectionPoolMBeanpublic void purgeOnReturn()
ConnectionPoolMBean.purge()purgeOnReturn in interface ConnectionPoolMBeanCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.