Interface ConnectionPoolMBean
- All Superinterfaces:
PoolConfiguration
- All Known Implementing Classes:
ConnectionPool, DataSource, XADataSource
JMX MBean interface for monitoring and managing a JDBC connection pool.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringNotification type sent when theSlowQueryReportJmxinterceptor reports a query that failed.static final StringNotification type sent when a connection that has been checked out longer than the remove-abandoned timeout is abandoned and removed from the pool.static final StringNotification type sent when the pool cannot establish a physical connection to the database.static final StringNotification type sent when the initialization of the pool fails, because an interceptor could not be started or because an initial connection of the pool could not be created and the failure is not ignored throughignoreExceptionOnPreLoad.static final StringNotification type sent when a borrow from the pool fails because the pool is empty: the borrower was not willing to wait for a connection or its wait timed out.static final StringNotification type sent when theSlowQueryReportJmxinterceptor reports a query that took longer than its configured threshold.static final StringNotification type sent when the pool marks a connection as suspect because it has been checked out longer than the suspect timeout and is therefore suspected of having been abandoned.static final StringNotification type sent when a connection that the pool had marked as suspect is returned to the pool.Fields inherited from interface PoolConfiguration
PKG_PREFIXModifier and TypeFieldDescriptionstatic final StringJMX prefix for interceptors that register themselves with JMX -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks for and removes abandoned connections from the pool.voidChecks and cleans up idle connections in the pool.intReturns the number of active (in-use) connections.longReturns the total number of connections borrowed since pool creation.longReturns the total number of connections created since pool creation.intgetIdle()Returns the number of idle connections in the pool.intReturns the number of active (in-use) connections.intReturns the number of idle connections in the pool.longReturns the total number of reconnections since pool creation.longReturns the total number of connections released since pool creation.longReturns the total number of idle connections released by the pool cleaner.longReturns the total number of connections removed due to abandonment.longReturns the total number of connections returned since pool creation.intgetSize()Returns the total number of connections in the pool.intReturns the number of threads waiting for a connection.voidpurge()Purges all connections in the pool.voidPurges connections when they are returned from the pool.voidreset the statistics of this pool.voidtestIdle()Validates all idle connections in the pool.Methods inherited from interface PoolConfiguration
getAbandonWhenPercentageFull, getCommitOnReturn, getConnectionProperties, getDataSource, getDataSourceJNDI, getDbProperties, getDefaultAutoCommit, getDefaultCatalog, getDefaultReadOnly, getDefaultTransactionIsolation, getDriverClassName, getInitialSize, getInitSQL, getJdbcInterceptors, getJdbcInterceptorsAsArray, getLogValidationErrors, getMaxActive, getMaxAge, getMaxIdle, getMaxWait, getMinEvictableIdleTimeMillis, getMinIdle, getName, getNumTestsPerEvictionRun, getPassword, getPoolName, getPropagateInterruptState, getRemoveAbandonedTimeout, getRollbackOnReturn, getSuspectTimeout, getTimeBetweenEvictionRunsMillis, getUrl, getUseDisposableConnectionFacade, getUseLock, getUsername, getUseStatementFacade, getValidationInterval, getValidationQuery, getValidationQueryTimeout, getValidator, getValidatorClassName, isAccessToUnderlyingConnectionAllowed, isAlternateUsernameAllowed, isDefaultAutoCommit, isDefaultReadOnly, isFairQueue, isIgnoreExceptionOnPreLoad, isJmxEnabled, isLogAbandoned, isPoolSweeperEnabled, isRemoveAbandoned, isTestOnBorrow, isTestOnConnect, isTestOnReturn, isTestWhileIdle, isUseEquals, setAbandonWhenPercentageFull, setAccessToUnderlyingConnectionAllowed, setAlternateUsernameAllowed, setCommitOnReturn, setConnectionProperties, setDataSource, setDataSourceJNDI, setDbProperties, setDefaultAutoCommit, setDefaultCatalog, setDefaultReadOnly, setDefaultTransactionIsolation, setDriverClassName, setFairQueue, setIgnoreExceptionOnPreLoad, setInitialSize, setInitSQL, setJdbcInterceptors, setJmxEnabled, setLogAbandoned, setLogValidationErrors, setMaxActive, setMaxAge, setMaxIdle, setMaxWait, setMinEvictableIdleTimeMillis, setMinIdle, setName, setNumTestsPerEvictionRun, setPassword, setPropagateInterruptState, setRemoveAbandoned, setRemoveAbandonedTimeout, setRollbackOnReturn, setSuspectTimeout, setTestOnBorrow, setTestOnConnect, setTestOnReturn, setTestWhileIdle, setTimeBetweenEvictionRunsMillis, setUrl, setUseDisposableConnectionFacade, setUseEquals, setUseLock, setUsername, setUseStatementFacade, setValidationInterval, setValidationQuery, setValidationQueryTimeout, setValidator, setValidatorClassNameModifier and TypeMethodDescriptionintConnections 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.booleanReturns whether the pool commits any pending transaction when a connection is returned.The connection properties that will be sent to the JDBC driver when establishing new connections.Returns a datasource, if one exists that is being used to create connections.Returns the JNDI string configured for data source usage.Returns the database properties that are passed into theDriver.connect(String, Properties)method.The default auto-commit state of connections created by this pool.If non null, during connection creation the methodConnection.setCatalog(String)will be called with the set value.If non null, during connection creation the methodConnection.setReadOnly(boolean)will be called with the set value.intReturns the default transaction isolation level.The fully qualified Java class name of the JDBC driver to be used.intReturns the number of connections that will be established when the connection pool is started.A custom query to be run when a connection is first created.A semicolon separated list of classnames extendingJdbcInterceptorclass.Returns thePoolConfiguration.getJdbcInterceptors()as an array of objects with properties and the classes.booleanReturns true if errors that happen during validation will be loggedintThe maximum number of active connections that can be allocated from this pool at the same time.longTime in milliseconds to keep this connection before reconnecting.intThe maximum number of connections that should be kept in the idle pool ifPoolConfiguration.isPoolSweeperEnabled()returns false.intThe maximum number of milliseconds that the pool will wait (when there are no available connections and thePoolConfiguration.getMaxActive()has been reached) for a connection to be returned before throwing an exception.intThe minimum amount of time an object must sit idle in the pool before it is eligible for eviction.intThe minimum number of established connections that should be kept in the pool at all times.getName()Returns the name of the connection pool.intProperty not usedReturns the password used when establishing connections to the database.Returns the name of the connection pool.booleanReturns true if the pool is configured to propagate interrupt state of a thread.intThe time in seconds before a connection can be considered abandoned.booleanReturns whether the pool rolls back any pending transaction when a connection is returned.intReturns the time in seconds to pass before a connection is marked an abandoned suspect.intThe number of milliseconds to sleep between runs of the idle connection validation, abandoned cleaner and idle pool resizing.getUrl()The URL used to connect to the databasebooleanDeprecated.The disposable connection facade is always used, so this property no longer has any effect.booleanReturn true if a lock should be used when operations are performed on the connection object.Returns the username used to establish the connection withbooleanDeprecated.The statement facade is always used, so this property no longer has any effect.longavoid excess validation, only run validation at most at this frequency - time in milliseconds.The SQL query that will be used to validate connections from this pool before returning them to the caller or pool.intThe timeout in seconds before a connection validation queries fail.Returns the validator object used for connection validation.Return the name of the optional validator class - may be null.booleanProperty not used.booleanReturns true if the callgetConnection(username,password)is allowed.The default auto-commit state of connections created by this pool.If non null, during connection creation the methodConnection.setReadOnly(boolean)will be called with the set value.booleanReturnstrueif a fair queue is being used by the connection poolbooleanReturns whether exceptions during connection creation at pool initialization should be ignored.booleanIf set to true, the connection pool creates aConnectionPoolMBeanobject that can be registered with JMX to receive notifications and state about the pool.booleanboolean flag to set if stack traces should be logged for application code which abandoned a Connection.booleanReturns true if the pool sweeper is enabled for the connection pool.booleanboolean flag to remove abandoned connections if they exceed the removeAbandonedTimeout.booleanThe indication of whether objects will be validated before being borrowed from the pool.booleanReturns true if we should run the validation query when connecting to the database for the first time on a connection.booleanThe indication of whether objects will be validated after being returned to the pool.booleanSet to true if query validation should take place while the connection is idle.booleanSet to true if you wish theProxyConnectionclass to useString.equalsinstead of==when comparing method names.voidsetAbandonWhenPercentageFull(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.voidsetAccessToUnderlyingConnectionAllowed(boolean accessToUnderlyingConnectionAllowed) No-opvoidsetAlternateUsernameAllowed(boolean alternateUsernameAllowed) Set to true if the callgetConnection(username,password)is allowed and honored..voidsetCommitOnReturn(boolean commitOnReturn) Set to true if you want the connection pool to commit any pending transaction when a connection is returned.voidsetConnectionProperties(String connectionProperties) The properties that will be passed intoDriver.connect(String, Properties)method.voidsetDataSource(Object ds) Injects a datasource that will be used to retrieve/create connections.voidsetDataSourceJNDI(String jndiDS) Configure the connection pool to use a DataSource according toPoolConfiguration.setDataSource(Object)But instead of injecting the object, specify the JNDI location.voidsetDbProperties(Properties dbProperties) Overrides the database properties passed into theDriver.connect(String, Properties)method.voidsetDefaultAutoCommit(Boolean defaultAutoCommit) The default auto-commit state of connections created by this pool.voidsetDefaultCatalog(String defaultCatalog) If non null, during connection creation the methodConnection.setCatalog(String)will be called with the set value.voidsetDefaultReadOnly(Boolean defaultReadOnly) If non null, during connection creation the methodConnection.setReadOnly(boolean)will be called with the set value.voidsetDefaultTransactionIsolation(int defaultTransactionIsolation) If set toDataSourceFactory.UNKNOWN_TRANSACTIONISOLATIONthe methodConnection.setTransactionIsolation(int)will not be called during connection creation.voidsetDriverClassName(String driverClassName) The fully qualified Java class name of the JDBC driver to be used.voidsetFairQueue(boolean fairQueue) Set to true if you wish that calls to getConnection should be treated fairly in a true FIFO fashion.voidsetIgnoreExceptionOnPreLoad(boolean ignoreExceptionOnPreLoad) Set to true if you want to ignore error of connection creation while initializing the pool.voidsetInitialSize(int initialSize) Set the number of connections that will be established when the connection pool is started.voidsetInitSQL(String initSQL) A custom query to be run when a connection is first created.voidsetJdbcInterceptors(String jdbcInterceptors) A semicolon separated list of classnames extendingJdbcInterceptorclass.voidsetJmxEnabled(boolean jmxEnabled) If set to true, the connection pool creates aConnectionPoolMBeanobject that can be registered with JMX to receive notifications and state about the pool.voidsetLogAbandoned(boolean logAbandoned) boolean flag to set if stack traces should be logged for application code which abandoned a Connection.voidsetLogValidationErrors(boolean logValidationErrors) Set to true if you wish that errors from validation should be logged as error messages.voidsetMaxActive(int maxActive) The maximum number of active connections that can be allocated from this pool at the same time.voidsetMaxAge(long maxAge) Time in milliseconds to keep this connection before reconnecting.voidsetMaxIdle(int maxIdle) The maximum number of connections that should be kept in the idle pool ifPoolConfiguration.isPoolSweeperEnabled()returns false.voidsetMaxWait(int maxWait) The maximum number of milliseconds that the pool will wait (when there are no available connections and thePoolConfiguration.getMaxActive()has been reached) for a connection to be returned before throwing an exception.voidsetMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) The minimum amount of time an object must sit idle in the pool before it is eligible for eviction.voidsetMinIdle(int minIdle) The minimum number of established connections that should be kept in the pool at all times.voidSets the name of the connection poolvoidsetNumTestsPerEvictionRun(int numTestsPerEvictionRun) Property not usedvoidsetPassword(String password) Sets the password to establish the connection with.voidsetPropagateInterruptState(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 aPoolExhaustedExceptionIf set to true, this behavior will change, while thePoolExhaustedExceptionis still thrown, the threads interrupted state is still set.voidsetRemoveAbandoned(boolean removeAbandoned) boolean flag to remove abandoned connections if they exceed the removeAbandonedTimeout.voidsetRemoveAbandonedTimeout(int removeAbandonedTimeout) The time in seconds before a connection can be considered abandoned.voidsetRollbackOnReturn(boolean rollbackOnReturn) Set to true if you want the connection pool to rollback any pending transaction when a connection is returned.voidsetSuspectTimeout(int seconds) Similar toPoolConfiguration.setRemoveAbandonedTimeout(int)but instead of treating the connection as abandoned, and potentially closing the connection, this simply logs the warning ifPoolConfiguration.isLogAbandoned()returns true.voidsetTestOnBorrow(boolean testOnBorrow) The indication of whether objects will be validated before being borrowed from the pool.voidsetTestOnConnect(boolean testOnConnect) Set to true if we should run the validation query when connecting to the database for the first time on a connection.voidsetTestOnReturn(boolean testOnReturn) The indication of whether objects will be validated after being returned to the pool.voidsetTestWhileIdle(boolean testWhileIdle) Set to true if query validation should take place while the connection is idle.voidsetTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) The number of milliseconds to sleep between runs of the idle connection validation, abandoned cleaner and idle pool resizing.voidSets the URL used to connect to the databasevoidsetUseDisposableConnectionFacade(boolean useDisposableConnectionFacade) Deprecated.The disposable connection facade is always used, so this property no longer has any effect.voidsetUseEquals(boolean useEquals) Set to true if you wish theProxyConnectionclass to useString.equalsinstead of==when comparing method names.voidsetUseLock(boolean useLock) Set to true if a lock should be used when operations are performed on the connection object.voidsetUsername(String username) Sets the username used to establish the connection with It will also be a property called 'user' in the database properties.voidsetUseStatementFacade(boolean useStatementFacade) Deprecated.The statement facade is always used, so this property no longer has any effect.voidsetValidationInterval(long validationInterval) avoid excess validation, only run validation at most at this frequency - time in milliseconds.voidsetValidationQuery(String validationQuery) The SQL query that will be used to validate connections from this pool before returning them to the caller or pool.voidsetValidationQueryTimeout(int validationQueryTimeout) The timeout in seconds before a connection validation queries fail.voidsetValidator(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.voidsetValidatorClassName(String className) Set the name for an optional validator class which will be used in place of test queries.
-
Field Details
-
NOTIFY_INIT
Notification type sent when the initialization of the pool fails, because an interceptor could not be started or because an initial connection of the pool could not be created and the failure is not ignored throughignoreExceptionOnPreLoad. The notification message carries the stack trace of the failure.- See Also:
-
NOTIFY_CONNECT
Notification type sent when the pool cannot establish a physical connection to the database. The notification message carries the stack trace of the connection failure.- See Also:
-
NOTIFY_ABANDON
Notification type sent when a connection that has been checked out longer than the remove-abandoned timeout is abandoned and removed from the pool. The notification message carries the stack trace of where the connection was borrowed, when the pool records those withlogAbandoned.- See Also:
-
SLOW_QUERY_NOTIFICATION
Notification type sent when theSlowQueryReportJmxinterceptor reports a query that took longer than its configured threshold. This pool MBean sends it only when the interceptor is configured withnotifyPool=true; otherwise the interceptor's own MBean sends the notification.- See Also:
-
FAILED_QUERY_NOTIFICATION
Notification type sent when theSlowQueryReportJmxinterceptor reports a query that failed. This pool MBean sends it only when the interceptor is configured withnotifyPool=true; otherwise the interceptor's own MBean sends the notification.- See Also:
-
SUSPECT_ABANDONED_NOTIFICATION
Notification type sent when the pool marks a connection as suspect because it has been checked out longer than the suspect timeout and is therefore suspected of having been abandoned. UnlikeNOTIFY_ABANDONthe connection is not removed from the pool. The notification message carries the stack trace of where the connection was borrowed, when the pool records those withlogAbandoned.- See Also:
-
POOL_EMPTY
Notification type sent when a borrow from the pool fails because the pool is empty: the borrower was not willing to wait for a connection or its wait timed out. It is sent once per failed borrow, so a pool that stays exhausted sends one per failed borrow attempt.- See Also:
-
SUSPECT_RETURNED_NOTIFICATION
Notification type sent when a connection that the pool had marked as suspect is returned to the pool.- See Also:
-
-
Method Details
-
getSize
int getSize()Returns the total number of connections in the pool.- Returns:
- total connection count
-
getIdle
int getIdle()Returns the number of idle connections in the pool.- Returns:
- idle connection count
-
getActive
int getActive()Returns the number of active (in-use) connections.- Returns:
- active connection count
-
getNumIdle
int getNumIdle()Returns the number of idle connections in the pool.- Returns:
- idle connection count
-
getNumActive
int getNumActive()Returns the number of active (in-use) connections.- Returns:
- active connection count
-
getWaitCount
int getWaitCount()Returns the number of threads waiting for a connection.- Returns:
- wait count
-
getBorrowedCount
long getBorrowedCount()Returns the total number of connections borrowed since pool creation.- Returns:
- borrowed count
-
getReturnedCount
long getReturnedCount()Returns the total number of connections returned since pool creation.- Returns:
- returned count
-
getCreatedCount
long getCreatedCount()Returns the total number of connections created since pool creation.- Returns:
- created count
-
getReleasedCount
long getReleasedCount()Returns the total number of connections released since pool creation.- Returns:
- released count
-
getReconnectedCount
long getReconnectedCount()Returns the total number of reconnections since pool creation.- Returns:
- reconnected count
-
getRemoveAbandonedCount
long getRemoveAbandonedCount()Returns the total number of connections removed due to abandonment.- Returns:
- abandoned count
-
getReleasedIdleCount
long getReleasedIdleCount()Returns the total number of idle connections released by the pool cleaner.- Returns:
- released idle count
-
checkIdle
void checkIdle()Checks and cleans up idle connections in the pool. -
checkAbandoned
void checkAbandoned()Checks for and removes abandoned connections from the pool. -
testIdle
void testIdle()Validates all idle connections in the pool. -
purge
void purge()Purges all connections in the pool. For connections currently in use, these connections will be purged when returned on the pool. This call also purges connections that are idle and in the pool To only purge used/active connections seepurgeOnReturn() -
purgeOnReturn
void purgeOnReturn()Purges connections when they are returned from the pool. This call does not purge idle connections until they are used. To purge idle connections seepurge() -
resetStats
void resetStats()reset the statistics of this pool.
-