@MXBean public interface DatabaseConnectionMonitor extends Monitor
Modifier and Type | Method and Description |
---|---|
void |
addConnectionProperty(String name,
String value)
Add a custom connection property to the set that will be passed to our
JDBC driver.
|
boolean |
getDefaultAutoCommit()
Returns the default auto-commit property.
|
String |
getDefaultCatalog()
Returns the default catalog.
|
boolean |
getDefaultReadOnly()
Returns the default readOnly property.
|
int |
getDefaultTransactionIsolation()
Returns the default transaction isolation state of returned connections.
|
String |
getDriverClassName()
Returns the jdbc driver class name.
|
int |
getInitialSize()
Returns the initial size of the connection pool.
|
boolean |
getLogAbandoned()
Flag to log stack traces for application code which abandoned
a Statement or Connection.
|
int |
getLoginTimeout()
BasicDataSource does NOT support this method.
|
int |
getMaxActive()
Returns the maximum number of active connections that can be
allocated at the same time.
|
int |
getMaxIdle()
Returns the maximum number of connections that can remain idle in the
pool.
|
int |
getMaxOpenPreparedStatements()
Gets the value of the
#maxOpenPreparedStatements property. |
long |
getMaxWait()
Returns the maximum number of milliseconds that the pool will wait
for a connection to be returned before throwing an exception.
|
long |
getMinEvictableIdleTimeMillis()
Returns the
#minEvictableIdleTimeMillis property. |
int |
getMinIdle()
Returns the minimum number of idle connections in the pool
|
int |
getNumActive()
[Read Only] The current number of active connections that have been
allocated from this data source.
|
int |
getNumIdle()
[Read Only] The current number of idle connections that are waiting
to be allocated from this data source.
|
int |
getNumTestsPerEvictionRun()
Returns the value of the
#numTestsPerEvictionRun property. |
boolean |
getRemoveAbandoned()
Flag to remove abandoned connections if they exceed the
removeAbandonedTimout.
|
int |
getRemoveAbandonedTimeout()
Timeout in seconds before an abandoned connection can be removed.
|
boolean |
getTestOnBorrow()
Returns the
#testOnBorrow property. |
boolean |
getTestOnReturn()
Returns the value of the
#testOnReturn property. |
boolean |
getTestWhileIdle()
Returns the value of the
#testWhileIdle property. |
long |
getTimeBetweenEvictionRunsMillis()
Returns the value of the
#timeBetweenEvictionRunsMillis
property. |
String |
getUrl()
Returns the JDBC connection
#url property. |
String |
getUsername()
Returns the JDBC connection
#username property. |
String |
getValidationQuery()
Returns the validation query used to validate connections before
returning them.
|
int |
getValidationQueryTimeout()
Returns the validation query timeout.
|
boolean |
isAccessToUnderlyingConnectionAllowed()
Returns the value of the accessToUnderlyingConnectionAllowed property.
|
boolean |
isClosed()
If true, this data source is closed and no more connections can be retrieved from this datasource.
|
boolean |
isPoolPreparedStatements()
Returns true if we are pooling statements.
|
void |
removeConnectionProperty(String name)
Remove a custom connection property.
|
void |
setAccessToUnderlyingConnectionAllowed(boolean allow)
Sets the value of the accessToUnderlyingConnectionAllowed property.
|
void |
setConnectionProperties(String connectionProperties)
Sets the connection properties passed to driver.connect(...).
|
void |
setDefaultAutoCommit(boolean defaultAutoCommit)
Sets default auto-commit state of connections returned by this
datasource.
|
void |
setDefaultCatalog(String defaultCatalog)
Sets the default catalog.
|
void |
setDefaultReadOnly(boolean defaultReadOnly)
Sets defaultReadonly property.
|
void |
setDefaultTransactionIsolation(int defaultTransactionIsolation)
Sets the default transaction isolation state for returned
connections.
|
void |
setLogAbandoned(boolean logAbandoned) |
void |
setLoginTimeout(int loginTimeout)
BasicDataSource does NOT support this method.
|
void |
setMaxActive(int maxActive)
Sets the maximum number of active connections that can be
allocated at the same time.
|
void |
setMaxIdle(int maxIdle)
Sets the maximum number of connections that can remain idle in the
pool.
|
void |
setMaxOpenPreparedStatements(int maxOpenStatements)
Sets the value of the
#maxOpenPreparedStatements
property. |
void |
setMaxWait(long maxWait)
Sets the maxWait property.
|
void |
setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)
Sets the
#minEvictableIdleTimeMillis property. |
void |
setMinIdle(int minIdle)
Sets the minimum number of idle connections in the pool.
|
void |
setNumTestsPerEvictionRun(int numTestsPerEvictionRun)
Sets the value of the
#numTestsPerEvictionRun property. |
void |
setPoolPreparedStatements(boolean poolingStatements)
Sets whether to pool statements or not.
|
void |
setRemoveAbandoned(boolean removeAbandoned) |
void |
setRemoveAbandonedTimeout(int removeAbandonedTimeout) |
void |
setTestOnBorrow(boolean testOnBorrow)
Sets the
#testOnBorrow property. |
void |
setTestOnReturn(boolean testOnReturn)
Sets the
testOnReturn property. |
void |
setTestWhileIdle(boolean testWhileIdle)
Sets the
testWhileIdle property. |
void |
setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)
Sets the
#timeBetweenEvictionRunsMillis property. |
void |
setValidationQuery(String validationQuery)
Sets the
#validationQuery . |
void |
setValidationQueryTimeout(int timeout)
Sets the validation query timeout, the amount of time, in seconds, that
connection validation will wait for a response from the database when
executing a validation query.
|
boolean getDefaultAutoCommit()
void setDefaultAutoCommit(boolean defaultAutoCommit)
Sets default auto-commit state of connections returned by this datasource.
Note: this method currently has no effect once the pool has been
initialized. The pool is initialized the first time one of the
following methods is invoked: getConnection, setLogwriter,
setLoginTimeout, getLoginTimeout, getLogWriter.
defaultAutoCommit
- default auto-commit valueboolean getDefaultReadOnly()
void setDefaultReadOnly(boolean defaultReadOnly)
Sets defaultReadonly property.
Note: this method currently has no effect once the pool has been
initialized. The pool is initialized the first time one of the
following methods is invoked: getConnection, setLogwriter,
setLoginTimeout, getLoginTimeout, getLogWriter.
defaultReadOnly
- default read-only valueint getDefaultTransactionIsolation()
Connection.getTransactionIsolation()
void setDefaultTransactionIsolation(int defaultTransactionIsolation)
Sets the default transaction isolation state for returned connections.
Note: this method currently has no effect once the pool has been
initialized. The pool is initialized the first time one of the
following methods is invoked: getConnection, setLogwriter,
setLoginTimeout, getLoginTimeout, getLogWriter.
defaultTransactionIsolation
- the default transaction isolation
stateConnection.getTransactionIsolation()
String getDefaultCatalog()
void setDefaultCatalog(String defaultCatalog)
Sets the default catalog.
Note: this method currently has no effect once the pool has been
initialized. The pool is initialized the first time one of the
following methods is invoked: getConnection, setLogwriter,
setLoginTimeout, getLoginTimeout, getLogWriter.
defaultCatalog
- the default catalogString getDriverClassName()
int getMaxActive()
Returns the maximum number of active connections that can be allocated at the same time.
A negative number means that there is no limit.
void setMaxActive(int maxActive)
maxActive
- the new value for maxActivegetMaxActive()
int getMaxIdle()
Returns the maximum number of connections that can remain idle in the pool.
A negative value indicates that there is no limit
void setMaxIdle(int maxIdle)
maxIdle
- the new value for maxIdlegetMaxIdle()
int getMinIdle()
GenericObjectPool.getMinIdle()
void setMinIdle(int minIdle)
minIdle
- the new value for minIdleGenericObjectPool.setMinIdle(int)
int getInitialSize()
long getMaxWait()
Returns the maximum number of milliseconds that the pool will wait for a connection to be returned before throwing an exception.
A value less than or equal to zero means the pool is set to wait indefinitely.
void setMaxWait(long maxWait)
Sets the maxWait property.
Use -1 to make the pool wait indefinitely.
maxWait
- the new value for maxWaitgetMaxWait()
boolean isPoolPreparedStatements()
void setPoolPreparedStatements(boolean poolingStatements)
Sets whether to pool statements or not.
Note: this method currently has no effect once the pool has been
initialized. The pool is initialized the first time one of the
following methods is invoked: getConnection, setLogwriter,
setLoginTimeout, getLoginTimeout, getLogWriter.
poolingStatements
- pooling on or offint getMaxOpenPreparedStatements()
#maxOpenPreparedStatements
property.#maxOpenPreparedStatements
void setMaxOpenPreparedStatements(int maxOpenStatements)
Sets the value of the #maxOpenPreparedStatements
property.
Note: this method currently has no effect once the pool has been
initialized. The pool is initialized the first time one of the
following methods is invoked: getConnection, setLogwriter,
setLoginTimeout, getLoginTimeout, getLogWriter.
maxOpenStatements
- the new maximum number of prepared statements#maxOpenPreparedStatements
boolean getTestOnBorrow()
#testOnBorrow
property.#testOnBorrow
void setTestOnBorrow(boolean testOnBorrow)
#testOnBorrow
property. This property determines
whether or not the pool will validate objects before they are borrowed
from the pool. For a true
value to have any effect, the
validationQuery
property must be set to a non-null string.testOnBorrow
- new value for testOnBorrow propertyboolean getTestOnReturn()
#testOnReturn
property.#testOnReturn
void setTestOnReturn(boolean testOnReturn)
testOnReturn
property. This property determines
whether or not the pool will validate objects before they are returned
to the pool. For a true
value to have any effect, the
validationQuery
property must be set to a non-null string.testOnReturn
- new value for testOnReturn propertylong getTimeBetweenEvictionRunsMillis()
#timeBetweenEvictionRunsMillis
property.#timeBetweenEvictionRunsMillis
void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)
#timeBetweenEvictionRunsMillis
property.timeBetweenEvictionRunsMillis
- the new time between evictor runs#timeBetweenEvictionRunsMillis
int getNumTestsPerEvictionRun()
#numTestsPerEvictionRun
property.#numTestsPerEvictionRun
void setNumTestsPerEvictionRun(int numTestsPerEvictionRun)
#numTestsPerEvictionRun
property.numTestsPerEvictionRun
- the new #numTestsPerEvictionRun
value#numTestsPerEvictionRun
long getMinEvictableIdleTimeMillis()
#minEvictableIdleTimeMillis
property.#minEvictableIdleTimeMillis
property#minEvictableIdleTimeMillis
void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)
#minEvictableIdleTimeMillis
property.minEvictableIdleTimeMillis
- the minimum amount of time an object
may sit idle in the pool#minEvictableIdleTimeMillis
boolean getTestWhileIdle()
#testWhileIdle
property.#testWhileIdle
void setTestWhileIdle(boolean testWhileIdle)
testWhileIdle
property. This property determines
whether or not the idle object evictor will validate connections. For a
true
value to have any effect, the
validationQuery
property must be set to a non-null string.testWhileIdle
- new value for testWhileIdle propertyint getNumActive()
int getNumIdle()
String getUrl()
#url
property.#url
passed to the JDBC driver to establish
connectionsString getUsername()
#username
property.#username
passed to the JDBC driver to establish
connectionsString getValidationQuery()
#validationQuery
void setValidationQuery(String validationQuery)
Sets the #validationQuery
.
Note: this method currently has no effect once the pool has been
initialized. The pool is initialized the first time one of the
following methods is invoked: getConnection, setLogwriter,
setLoginTimeout, getLoginTimeout, getLogWriter.
validationQuery
- the new value for the validation queryint getValidationQueryTimeout()
void setValidationQueryTimeout(int timeout)
Note: this method currently has no effect once the pool has been
initialized. The pool is initialized the first time one of the
following methods is invoked: getConnection, setLogwriter,
setLoginTimeout, getLoginTimeout, getLogWriter.
timeout
- new validation query timeout value in secondsboolean isAccessToUnderlyingConnectionAllowed()
void setAccessToUnderlyingConnectionAllowed(boolean allow)
Sets the value of the accessToUnderlyingConnectionAllowed property. It controls if the PoolGuard allows access to the underlying connection. (Default: false)
Note: this method currently has no effect once the pool has been
initialized. The pool is initialized the first time one of the
following methods is invoked: getConnection, setLogwriter,
setLoginTimeout, getLoginTimeout, getLogWriter.
allow
- Access to the underlying connection is granted when true.int getLoginTimeout() throws SQLException
Returns the login timeout (in seconds) for connecting to the database.
Calls #createDataSource()
, so has the side effect
of initializing the connection pool.
SQLException
- if a database access error occursUnsupportedOperationException
- If the DataSource implementation
does not support the login timeout feature.void setLoginTimeout(int loginTimeout) throws SQLException
Set the login timeout (in seconds) for connecting to the database.
Calls #createDataSource()
, so has the side effect
of initializing the connection pool.
loginTimeout
- The new login timeout, or zero for no timeoutUnsupportedOperationException
- If the DataSource implementation
does not support the login timeout feature.SQLException
- if a database access error occursboolean getRemoveAbandoned()
Abandonded connections are identified and removed when
#getConnection()
is invoked and the following conditions hold
getRemoveAbandoned()
= true getNumActive()
> getMaxActive()
- 3 getNumIdle()
< 2 void setRemoveAbandoned(boolean removeAbandoned)
removeAbandoned
- new removeAbandoned property valuegetRemoveAbandoned()
int getRemoveAbandonedTimeout()
void setRemoveAbandonedTimeout(int removeAbandonedTimeout)
removeAbandonedTimeout
- new removeAbandonedTimeout valueboolean getLogAbandoned()
Flag to log stack traces for application code which abandoned a Statement or Connection.
Defaults to false.
Logging of abandoned Statements and Connections adds overhead for every Connection open or new Statement because a stack trace has to be generated.
void setLogAbandoned(boolean logAbandoned)
logAbandoned
- new logAbandoned property valuevoid addConnectionProperty(String name, String value)
name
- Name of the custom connection propertyvalue
- Value of the custom connection propertyvoid removeConnectionProperty(String name)
name
- Name of the custom connection property to removeaddConnectionProperty(String, String)
void setConnectionProperties(String connectionProperties)
connectionProperties
- the connection properties used to
create new connectionsboolean isClosed()
Copyright © 2014 Nuxeo SA. All Rights Reserved.