Class InstanceKeyDataSource
- java.lang.Object
- 
- org.apache.tomcat.dbcp.dbcp2.datasources.InstanceKeyDataSource
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.AutoCloseable,- java.sql.Wrapper,- javax.naming.Referenceable,- javax.sql.CommonDataSource,- javax.sql.DataSource
 - Direct Known Subclasses:
- PerUserPoolDataSource,- SharedPoolDataSource
 
 public abstract class InstanceKeyDataSource extends java.lang.Object implements javax.sql.DataSource, javax.naming.Referenceable, java.io.Serializable, java.lang.AutoCloseableThe base class for SharedPoolDataSourceandPerUserPoolDataSource. Many of the configuration properties are shared and defined here. This class is declared public in order to allow particular usage with commons-beanutils; do not make direct use of it outside of commons-dbcp2.A J2EE container will normally provide some method of initializing the DataSourcewhose attributes are presented as bean getters/setters and then deploying it via JNDI. It is then available to an application as a source of pooled logical connections to the database. The pool needs a source of physical connections. This source is in the form of aConnectionPoolDataSourcethat can be specified via thesetDataSourceName(String)used to lookup the source via JNDI.Although normally used within a JNDI environment, A DataSource can be instantiated and initialized as any bean. In this case the ConnectionPoolDataSourcewill likely be instantiated in a similar manner. This class allows the physical source of connections to be attached directly to this pool using thesetConnectionPoolDataSource(ConnectionPoolDataSource)method.The dbcp package contains an adapter, DriverAdapterCPDS, that can be used to allow the use ofDataSource's based on this class with JDBC driver implementations that do not supply aConnectionPoolDataSource, but still provide aDriverimplementation.The package documentation contains an example using Apache Tomcat and JNDI and it also contains a non-JNDI example. - Since:
- 2.0
- See Also:
- Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected static intUNKNOWN_TRANSACTIONISOLATIONInternal constant to indicate the level is not set.
 - 
Constructor SummaryConstructors Constructor Description InstanceKeyDataSource()Default no-arg constructor for Serialization.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidassertInitializationAllowed()Throws an IllegalStateException, if a PooledConnection has already been requested.abstract voidclose()Closes the connection pool being maintained by this datasource.java.sql.ConnectiongetConnection()Attempts to establish a database connection.java.sql.ConnectiongetConnection(java.lang.String userName, java.lang.String userPassword)Attempts to retrieve a database connection usinggetPooledConnectionAndInfo(String, String)with the provided user name and password.protected abstract org.apache.tomcat.dbcp.dbcp2.datasources.PooledConnectionManagergetConnectionManager(org.apache.tomcat.dbcp.dbcp2.datasources.UserPassKey upkey)javax.sql.ConnectionPoolDataSourcegetConnectionPoolDataSource()Gets the value of connectionPoolDataSource.java.lang.StringgetDataSourceName()Gets the name of the ConnectionPoolDataSource which backs this pool.booleangetDefaultBlockWhenExhausted()Gets the default value forBaseObjectPoolConfig.getBlockWhenExhausted()for each per user pool.java.time.DurationgetDefaultDurationBetweenEvictionRuns()Gets the default value forBaseGenericObjectPool.getDurationBetweenEvictionRuns()for each per user pool.java.lang.StringgetDefaultEvictionPolicyClassName()Gets the default value forBaseObjectPoolConfig.getEvictionPolicyClassName()for each per user pool.booleangetDefaultLifo()Gets the default value forBaseObjectPoolConfig.getLifo()for each per user pool.intgetDefaultMaxIdle()Gets the default value forGenericKeyedObjectPoolConfig.getMaxIdlePerKey()for each per user pool.intgetDefaultMaxTotal()Gets the default value forGenericKeyedObjectPoolConfig.getMaxTotalPerKey()for each per user pool.java.time.DurationgetDefaultMaxWait()Gets the default value forBaseObjectPoolConfig.getMaxWaitDuration()for each per user pool.longgetDefaultMaxWaitMillis()Deprecated.UsegetDefaultMaxWait().java.time.DurationgetDefaultMinEvictableIdleDuration()Gets the default value forBaseObjectPoolConfig.getMinEvictableIdleDuration()for each per user pool.longgetDefaultMinEvictableIdleTimeMillis()Deprecated.intgetDefaultMinIdle()Gets the default value forGenericKeyedObjectPoolConfig.getMinIdlePerKey()for each per user pool.intgetDefaultNumTestsPerEvictionRun()Gets the default value forBaseObjectPoolConfig.getNumTestsPerEvictionRun()for each per user pool.java.time.DurationgetDefaultSoftMinEvictableIdleDuration()Gets the default value forGenericObjectPool#getSoftMinEvictableIdleTimeMillis()for each per user pool.longgetDefaultSoftMinEvictableIdleTimeMillis()Deprecated.booleangetDefaultTestOnBorrow()Gets the default value forGenericObjectPool#getTestOnBorrow()for each per user pool.booleangetDefaultTestOnCreate()Gets the default value forGenericObjectPool#getTestOnCreate()for each per user pool.booleangetDefaultTestOnReturn()Gets the default value forGenericObjectPool#getTestOnReturn()for each per user pool.booleangetDefaultTestWhileIdle()Gets the default value forGenericObjectPool#getTestWhileIdle()for each per user pool.longgetDefaultTimeBetweenEvictionRunsMillis()Deprecated.intgetDefaultTransactionIsolation()Gets the value of defaultTransactionIsolation, which defines the state of connections handed out from this pool.java.lang.StringgetDescription()Gets the description.protected java.lang.StringgetInstanceKey()Gets the instance key.java.lang.StringgetJndiEnvironment(java.lang.String key)Gets the value of jndiEnvironment which is used when instantiating a JNDI InitialContext.intgetLoginTimeout()Deprecated.java.time.DurationgetLoginTimeoutDuration()Gets the value of loginTimeout.java.io.PrintWritergetLogWriter()Gets the value of logWriter.java.time.DurationgetMaxConnDuration()Gets the maximum permitted lifetime of a connection.java.time.DurationgetMaxConnLifetime()Deprecated.UsegetMaxConnDuration().longgetMaxConnLifetimeMillis()Deprecated.UsegetMaxConnLifetime().java.util.logging.LoggergetParentLogger()protected abstract org.apache.tomcat.dbcp.dbcp2.datasources.PooledConnectionAndInfogetPooledConnectionAndInfo(java.lang.String userName, java.lang.String userPassword)This method is protected but can only be implemented in this package because PooledConnectionAndInfo is a package private type.java.lang.StringgetValidationQuery()Gets the SQL query that will be used to validate connections from this pool before returning them to the caller.intgetValidationQueryTimeout()Deprecated.java.time.DurationgetValidationQueryTimeoutDuration()Returns the timeout Duration before the validation query fails.java.lang.BooleanisDefaultAutoCommit()Gets the value of defaultAutoCommit, which defines the state of connections handed out from this pool.java.lang.BooleanisDefaultReadOnly()Gets the value of defaultReadOnly, which defines the state of connections handed out from this pool.booleanisRollbackAfterValidation()Whether a rollback will be issued after executing the SQL query that will be used to validate connections from this pool before returning them to the caller.booleanisWrapperFor(java.lang.Class<?> iface)voidsetConnectionPoolDataSource(javax.sql.ConnectionPoolDataSource dataSource)Sets the back end ConnectionPoolDataSource.voidsetDataSourceName(java.lang.String dataSourceName)Sets the name of the ConnectionPoolDataSource which backs this pool.voidsetDefaultAutoCommit(java.lang.Boolean defaultAutoCommit)Sets the value of defaultAutoCommit, which defines the state of connections handed out from this pool.voidsetDefaultBlockWhenExhausted(boolean blockWhenExhausted)Sets the default value forBaseObjectPoolConfig.getBlockWhenExhausted()for each per user pool.voidsetDefaultDurationBetweenEvictionRuns(java.time.Duration defaultDurationBetweenEvictionRuns)Sets the default value for()for each per user pool.voidsetDefaultEvictionPolicyClassName(java.lang.String evictionPolicyClassName)Sets the default value forBaseObjectPoolConfig.getEvictionPolicyClassName()for each per user pool.voidsetDefaultLifo(boolean lifo)Sets the default value forBaseObjectPoolConfig.getLifo()for each per user pool.voidsetDefaultMaxIdle(int maxIdle)Sets the default value forGenericKeyedObjectPoolConfig.getMaxIdlePerKey()for each per user pool.voidsetDefaultMaxTotal(int maxTotal)Sets the default value forGenericKeyedObjectPoolConfig.getMaxTotalPerKey()for each per user pool.voidsetDefaultMaxWait(java.time.Duration maxWaitMillis)Sets the default value forBaseObjectPoolConfig.getMaxWaitDuration()for each per user pool.voidsetDefaultMaxWaitMillis(long maxWaitMillis)Deprecated.voidsetDefaultMinEvictableIdle(java.time.Duration defaultMinEvictableIdleDuration)Sets the default value forBaseObjectPoolConfig.getMinEvictableIdleDuration()for each per user pool.voidsetDefaultMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)Deprecated.voidsetDefaultMinIdle(int minIdle)Sets the default value forGenericKeyedObjectPoolConfig.getMinIdlePerKey()for each per user pool.voidsetDefaultNumTestsPerEvictionRun(int numTestsPerEvictionRun)Sets the default value forBaseObjectPoolConfig.getNumTestsPerEvictionRun()for each per user pool.voidsetDefaultReadOnly(java.lang.Boolean defaultReadOnly)Sets the value of defaultReadOnly, which defines the state of connections handed out from this pool.voidsetDefaultSoftMinEvictableIdle(java.time.Duration defaultSoftMinEvictableIdleDuration)Sets the default value forGenericObjectPool#getSoftMinEvictableIdleTimeMillis()for each per user pool.voidsetDefaultSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis)Deprecated.voidsetDefaultTestOnBorrow(boolean testOnBorrow)Sets the default value forGenericObjectPool#getTestOnBorrow()for each per user pool.voidsetDefaultTestOnCreate(boolean testOnCreate)Sets the default value forGenericObjectPool#getTestOnCreate()for each per user pool.voidsetDefaultTestOnReturn(boolean testOnReturn)Sets the default value forGenericObjectPool#getTestOnReturn()for each per user pool.voidsetDefaultTestWhileIdle(boolean testWhileIdle)Sets the default value forGenericObjectPool#getTestWhileIdle()for each per user pool.voidsetDefaultTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)Deprecated.voidsetDefaultTransactionIsolation(int defaultTransactionIsolation)Sets the value of defaultTransactionIsolation, which defines the state of connections handed out from this pool.voidsetDescription(java.lang.String description)Sets the description.voidsetJndiEnvironment(java.lang.String key, java.lang.String value)Sets the value of the given JNDI environment property to be used when instantiating a JNDI InitialContext.voidsetLoginTimeout(int loginTimeout)Deprecated.voidsetLoginTimeout(java.time.Duration loginTimeout)Sets the value of loginTimeout.voidsetLogWriter(java.io.PrintWriter logWriter)Sets the value of logWriter.voidsetMaxConnLifetime(java.time.Duration maxConnLifetimeMillis)Sets the maximum permitted lifetime of a connection.voidsetMaxConnLifetimeMillis(long maxConnLifetimeMillis)Deprecated.voidsetRollbackAfterValidation(boolean rollbackAfterValidation)Whether a rollback will be issued after executing the SQL query that will be used to validate connections from this pool before returning them to the caller.protected abstract voidsetupDefaults(java.sql.Connection connection, java.lang.String userName)voidsetValidationQuery(java.lang.String validationQuery)Sets the SQL query that will be used to validate connections from this pool before returning them to the caller.voidsetValidationQueryTimeout(int validationQueryTimeoutSeconds)Deprecated.voidsetValidationQueryTimeout(java.time.Duration validationQueryTimeoutDuration)Sets the timeout duration before the validation query fails.protected javax.sql.ConnectionPoolDataSourcetestCPDS(java.lang.String userName, java.lang.String userPassword)java.lang.StringtoString()protected voidtoStringFields(java.lang.StringBuilder builder)<T> Tunwrap(java.lang.Class<T> iface)
 
- 
- 
- 
Field Detail- 
UNKNOWN_TRANSACTIONISOLATIONprotected static final int UNKNOWN_TRANSACTIONISOLATION Internal constant to indicate the level is not set.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
assertInitializationAllowedprotected void assertInitializationAllowed() throws java.lang.IllegalStateExceptionThrows an IllegalStateException, if a PooledConnection has already been requested.- Throws:
- java.lang.IllegalStateException- Thrown if a PooledConnection has already been requested.
 
 - 
closepublic abstract void close() throws java.sql.SQLExceptionCloses the connection pool being maintained by this datasource.- Specified by:
- closein interface- java.lang.AutoCloseable
- Throws:
- java.sql.SQLException
 
 - 
getConnectionpublic java.sql.Connection getConnection() throws java.sql.SQLExceptionAttempts to establish a database connection.- Specified by:
- getConnectionin interface- javax.sql.DataSource
- Throws:
- java.sql.SQLException
 
 - 
getConnectionpublic java.sql.Connection getConnection(java.lang.String userName, java.lang.String userPassword) throws java.sql.SQLExceptionAttempts to retrieve a database connection usinggetPooledConnectionAndInfo(String, String)with the provided user name and password. The password on thePooledConnectionAndInfoinstance returned bygetPooledConnectionAndInfois compared to thepasswordparameter. If the comparison fails, a database connection using the supplied user name and password is attempted. If the connection attempt fails, an SQLException is thrown, indicating that the given password did not match the password used to create the pooled connection. If the connection attempt succeeds, this means that the database password has been changed. In this case, thePooledConnectionAndInfoinstance retrieved with the old password is destroyed and thegetPooledConnectionAndInfois repeatedly invoked until aPooledConnectionAndInfoinstance with the new password is returned.- Specified by:
- getConnectionin interface- javax.sql.DataSource
- Throws:
- java.sql.SQLException
 
 - 
getConnectionManagerprotected abstract org.apache.tomcat.dbcp.dbcp2.datasources.PooledConnectionManager getConnectionManager(org.apache.tomcat.dbcp.dbcp2.datasources.UserPassKey upkey) 
 - 
getConnectionPoolDataSourcepublic javax.sql.ConnectionPoolDataSource getConnectionPoolDataSource() Gets the value of connectionPoolDataSource. This method will return null, if the backing data source is being accessed via JNDI.- Returns:
- value of connectionPoolDataSource.
 
 - 
getDataSourceNamepublic java.lang.String getDataSourceName() Gets the name of the ConnectionPoolDataSource which backs this pool. This name is used to look up the data source from a JNDI service provider.- Returns:
- value of dataSourceName.
 
 - 
getDefaultBlockWhenExhaustedpublic boolean getDefaultBlockWhenExhausted() Gets the default value forBaseObjectPoolConfig.getBlockWhenExhausted()for each per user pool.- Returns:
- The default value for BaseObjectPoolConfig.getBlockWhenExhausted()for each per user pool.
 
 - 
getDefaultDurationBetweenEvictionRunspublic java.time.Duration getDefaultDurationBetweenEvictionRuns() Gets the default value forBaseGenericObjectPool.getDurationBetweenEvictionRuns()for each per user pool.- Returns:
- The default value for BaseGenericObjectPool.getDurationBetweenEvictionRuns()for each per user pool.
- Since:
- 2.10.0
 
 - 
getDefaultEvictionPolicyClassNamepublic java.lang.String getDefaultEvictionPolicyClassName() Gets the default value forBaseObjectPoolConfig.getEvictionPolicyClassName()for each per user pool.- Returns:
- The default value for BaseObjectPoolConfig.getEvictionPolicyClassName()for each per user pool.
 
 - 
getDefaultLifopublic boolean getDefaultLifo() Gets the default value forBaseObjectPoolConfig.getLifo()for each per user pool.- Returns:
- The default value for BaseObjectPoolConfig.getLifo()for each per user pool.
 
 - 
getDefaultMaxIdlepublic int getDefaultMaxIdle() Gets the default value forGenericKeyedObjectPoolConfig.getMaxIdlePerKey()for each per user pool.- Returns:
- The default value for GenericKeyedObjectPoolConfig.getMaxIdlePerKey()for each per user pool.
 
 - 
getDefaultMaxTotalpublic int getDefaultMaxTotal() Gets the default value forGenericKeyedObjectPoolConfig.getMaxTotalPerKey()for each per user pool.- Returns:
- The default value for GenericKeyedObjectPoolConfig.getMaxTotalPerKey()for each per user pool.
 
 - 
getDefaultMaxWaitpublic java.time.Duration getDefaultMaxWait() Gets the default value forBaseObjectPoolConfig.getMaxWaitDuration()for each per user pool.- Returns:
- The default value for BaseObjectPoolConfig.getMaxWaitDuration()for each per user pool.
- Since:
- 2.9.0
 
 - 
getDefaultMaxWaitMillis@Deprecated public long getDefaultMaxWaitMillis() Deprecated.UsegetDefaultMaxWait().Gets the default value forBaseObjectPoolConfig.getMaxWaitDuration()for each per user pool.- Returns:
- The default value for BaseObjectPoolConfig.getMaxWaitDuration()for each per user pool.
 
 - 
getDefaultMinEvictableIdleDurationpublic java.time.Duration getDefaultMinEvictableIdleDuration() Gets the default value forBaseObjectPoolConfig.getMinEvictableIdleDuration()for each per user pool.- Returns:
- The default value for BaseObjectPoolConfig.getMinEvictableIdleDuration()for each per user pool.
- Since:
- 2.10.0
 
 - 
getDefaultMinEvictableIdleTimeMillis@Deprecated public long getDefaultMinEvictableIdleTimeMillis() Deprecated.Gets the default value forBaseObjectPoolConfig.getMinEvictableIdleDuration()for each per user pool.- Returns:
- The default value for BaseObjectPoolConfig.getMinEvictableIdleDuration()for each per user pool.
 
 - 
getDefaultMinIdlepublic int getDefaultMinIdle() Gets the default value forGenericKeyedObjectPoolConfig.getMinIdlePerKey()for each per user pool.- Returns:
- The default value for GenericKeyedObjectPoolConfig.getMinIdlePerKey()for each per user pool.
 
 - 
getDefaultNumTestsPerEvictionRunpublic int getDefaultNumTestsPerEvictionRun() Gets the default value forBaseObjectPoolConfig.getNumTestsPerEvictionRun()for each per user pool.- Returns:
- The default value for BaseObjectPoolConfig.getNumTestsPerEvictionRun()for each per user pool.
 
 - 
getDefaultSoftMinEvictableIdleDurationpublic java.time.Duration getDefaultSoftMinEvictableIdleDuration() Gets the default value forGenericObjectPool#getSoftMinEvictableIdleTimeMillis()for each per user pool.- Returns:
- The default value for GenericObjectPool#getSoftMinEvictableIdleTimeMillis()for each per user pool.
- Since:
- 2.10.0
 
 - 
getDefaultSoftMinEvictableIdleTimeMillis@Deprecated public long getDefaultSoftMinEvictableIdleTimeMillis() Deprecated.Gets the default value forGenericObjectPool#getSoftMinEvictableIdleTimeMillis()for each per user pool.- Returns:
- The default value for GenericObjectPool#getSoftMinEvictableIdleTimeMillis()for each per user pool.
 
 - 
getDefaultTestOnBorrowpublic boolean getDefaultTestOnBorrow() Gets the default value forGenericObjectPool#getTestOnBorrow()for each per user pool.- Returns:
- The default value for GenericObjectPool#getTestOnBorrow()for each per user pool.
 
 - 
getDefaultTestOnCreatepublic boolean getDefaultTestOnCreate() Gets the default value forGenericObjectPool#getTestOnCreate()for each per user pool.- Returns:
- The default value for GenericObjectPool#getTestOnCreate()for each per user pool.
 
 - 
getDefaultTestOnReturnpublic boolean getDefaultTestOnReturn() Gets the default value forGenericObjectPool#getTestOnReturn()for each per user pool.- Returns:
- The default value for GenericObjectPool#getTestOnReturn()for each per user pool.
 
 - 
getDefaultTestWhileIdlepublic boolean getDefaultTestWhileIdle() Gets the default value forGenericObjectPool#getTestWhileIdle()for each per user pool.- Returns:
- The default value for GenericObjectPool#getTestWhileIdle()for each per user pool.
 
 - 
getDefaultTimeBetweenEvictionRunsMillis@Deprecated public long getDefaultTimeBetweenEvictionRunsMillis() Deprecated.Gets the default value for()for each per user pool.- Returns:
- The default value for ()for each per user pool.
 
 - 
getDefaultTransactionIsolationpublic int getDefaultTransactionIsolation() Gets the value of defaultTransactionIsolation, which defines the state of connections handed out from this pool. The value can be changed on the Connection using Connection.setTransactionIsolation(int). If this method returns -1, the default is JDBC driver dependent.- Returns:
- value of defaultTransactionIsolation.
 
 - 
getDescriptionpublic java.lang.String getDescription() Gets the description. This property is defined by JDBC as for use with GUI (or other) tools that might deploy the datasource. It serves no internal purpose.- Returns:
- value of description.
 
 - 
getInstanceKeyprotected java.lang.String getInstanceKey() Gets the instance key.- Returns:
- the instance key.
 
 - 
getJndiEnvironmentpublic java.lang.String getJndiEnvironment(java.lang.String key) Gets the value of jndiEnvironment which is used when instantiating a JNDI InitialContext. This InitialContext is used to locate the back end ConnectionPoolDataSource.- Parameters:
- key- JNDI environment key.
- Returns:
- value of jndiEnvironment.
 
 - 
getLoginTimeout@Deprecated public int getLoginTimeout() Deprecated.Gets the value of loginTimeout.- Specified by:
- getLoginTimeoutin interface- javax.sql.CommonDataSource
- Specified by:
- getLoginTimeoutin interface- javax.sql.DataSource
- Returns:
- value of loginTimeout.
 
 - 
getLoginTimeoutDurationpublic java.time.Duration getLoginTimeoutDuration() Gets the value of loginTimeout.- Returns:
- value of loginTimeout.
- Since:
- 2.10.0
 
 - 
getLogWriterpublic java.io.PrintWriter getLogWriter() Gets the value of logWriter.- Specified by:
- getLogWriterin interface- javax.sql.CommonDataSource
- Specified by:
- getLogWriterin interface- javax.sql.DataSource
- Returns:
- value of logWriter.
 
 - 
getMaxConnDurationpublic java.time.Duration getMaxConnDuration() Gets the maximum permitted lifetime of a connection. A value of zero or less indicates an infinite lifetime.- Returns:
- The maximum permitted lifetime of a connection. A value of zero or less indicates an infinite lifetime.
- Since:
- 2.10.0
 
 - 
getMaxConnLifetime@Deprecated public java.time.Duration getMaxConnLifetime() Deprecated.UsegetMaxConnDuration().Gets the maximum permitted lifetime of a connection. A value of zero or less indicates an infinite lifetime.- Returns:
- The maximum permitted lifetime of a connection. A value of zero or less indicates an infinite lifetime.
 
 - 
getMaxConnLifetimeMillis@Deprecated public long getMaxConnLifetimeMillis() Deprecated.UsegetMaxConnLifetime().Gets the maximum permitted lifetime of a connection in milliseconds. A value of zero or less indicates an infinite lifetime.- Returns:
- The maximum permitted lifetime of a connection in milliseconds. A value of zero or less indicates an infinite lifetime.
 
 - 
getParentLoggerpublic java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException- Specified by:
- getParentLoggerin interface- javax.sql.CommonDataSource
- Throws:
- java.sql.SQLFeatureNotSupportedException
 
 - 
getPooledConnectionAndInfoprotected abstract org.apache.tomcat.dbcp.dbcp2.datasources.PooledConnectionAndInfo getPooledConnectionAndInfo(java.lang.String userName, java.lang.String userPassword) throws java.sql.SQLExceptionThis method is protected but can only be implemented in this package because PooledConnectionAndInfo is a package private type.- Parameters:
- userName- The user name.
- userPassword- The user password.
- Returns:
- Matching PooledConnectionAndInfo.
- Throws:
- java.sql.SQLException- Connection or registration failure.
 
 - 
getValidationQuerypublic java.lang.String getValidationQuery() Gets the SQL query that will be used to validate connections from this pool before returning them to the caller. If specified, this query MUST be an SQL SELECT statement that returns at least one row. If not specified,Connection.isValid(int)will be used to validate connections.- Returns:
- The SQL query that will be used to validate connections from this pool before returning them to the caller.
 
 - 
getValidationQueryTimeout@Deprecated public int getValidationQueryTimeout() Deprecated.Returns the timeout in seconds before the validation query fails.- Returns:
- The timeout in seconds before the validation query fails.
 
 - 
getValidationQueryTimeoutDurationpublic java.time.Duration getValidationQueryTimeoutDuration() Returns the timeout Duration before the validation query fails.- Returns:
- The timeout Duration before the validation query fails.
 
 - 
isDefaultAutoCommitpublic java.lang.Boolean isDefaultAutoCommit() Gets the value of defaultAutoCommit, which defines the state of connections handed out from this pool. The value can be changed on the Connection using Connection.setAutoCommit(boolean). The default isnullwhich will use the default value for the drive.- Returns:
- value of defaultAutoCommit.
 
 - 
isDefaultReadOnlypublic java.lang.Boolean isDefaultReadOnly() Gets the value of defaultReadOnly, which defines the state of connections handed out from this pool. The value can be changed on the Connection using Connection.setReadOnly(boolean). The default isnullwhich will use the default value for the drive.- Returns:
- value of defaultReadOnly.
 
 - 
isRollbackAfterValidationpublic boolean isRollbackAfterValidation() Whether a rollback will be issued after executing the SQL query that will be used to validate connections from this pool before returning them to the caller.- Returns:
- true if a rollback will be issued after executing the validation query
 
 - 
isWrapperForpublic boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException- Specified by:
- isWrapperForin interface- java.sql.Wrapper
- Throws:
- java.sql.SQLException
 
 - 
setConnectionPoolDataSourcepublic void setConnectionPoolDataSource(javax.sql.ConnectionPoolDataSource dataSource) Sets the back end ConnectionPoolDataSource. This property should not be set if using JNDI to access the data source.- Parameters:
- dataSource- Value to assign to connectionPoolDataSource.
 
 - 
setDataSourceNamepublic void setDataSourceName(java.lang.String dataSourceName) Sets the name of the ConnectionPoolDataSource which backs this pool. This name is used to look up the data source from a JNDI service provider.- Parameters:
- dataSourceName- Value to assign to dataSourceName.
 
 - 
setDefaultAutoCommitpublic void setDefaultAutoCommit(java.lang.Boolean defaultAutoCommit) Sets the value of defaultAutoCommit, which defines the state of connections handed out from this pool. The value can be changed on the Connection using Connection.setAutoCommit(boolean). The default isnullwhich will use the default value for the drive.- Parameters:
- defaultAutoCommit- Value to assign to defaultAutoCommit.
 
 - 
setDefaultBlockWhenExhaustedpublic void setDefaultBlockWhenExhausted(boolean blockWhenExhausted) Sets the default value forBaseObjectPoolConfig.getBlockWhenExhausted()for each per user pool.- Parameters:
- blockWhenExhausted- The default value for- BaseObjectPoolConfig.getBlockWhenExhausted()for each per user pool.
 
 - 
setDefaultDurationBetweenEvictionRunspublic void setDefaultDurationBetweenEvictionRuns(java.time.Duration defaultDurationBetweenEvictionRuns) Sets the default value for()for each per user pool.- Parameters:
- defaultDurationBetweenEvictionRuns- The default value for- ()for each per user pool.
- Since:
- 2.10.0
 
 - 
setDefaultEvictionPolicyClassNamepublic void setDefaultEvictionPolicyClassName(java.lang.String evictionPolicyClassName) Sets the default value forBaseObjectPoolConfig.getEvictionPolicyClassName()for each per user pool.- Parameters:
- evictionPolicyClassName- The default value for- BaseObjectPoolConfig.getEvictionPolicyClassName()for each per user pool.
 
 - 
setDefaultLifopublic void setDefaultLifo(boolean lifo) Sets the default value forBaseObjectPoolConfig.getLifo()for each per user pool.- Parameters:
- lifo- The default value for- BaseObjectPoolConfig.getLifo()for each per user pool.
 
 - 
setDefaultMaxIdlepublic void setDefaultMaxIdle(int maxIdle) Sets the default value forGenericKeyedObjectPoolConfig.getMaxIdlePerKey()for each per user pool.- Parameters:
- maxIdle- The default value for- GenericKeyedObjectPoolConfig.getMaxIdlePerKey()for each per user pool.
 
 - 
setDefaultMaxTotalpublic void setDefaultMaxTotal(int maxTotal) Sets the default value forGenericKeyedObjectPoolConfig.getMaxTotalPerKey()for each per user pool.- Parameters:
- maxTotal- The default value for- GenericKeyedObjectPoolConfig.getMaxTotalPerKey()for each per user pool.
 
 - 
setDefaultMaxWaitpublic void setDefaultMaxWait(java.time.Duration maxWaitMillis) Sets the default value forBaseObjectPoolConfig.getMaxWaitDuration()for each per user pool.- Parameters:
- maxWaitMillis- The default value for- BaseObjectPoolConfig.getMaxWaitDuration()for each per user pool.
- Since:
- 2.9.0
 
 - 
setDefaultMaxWaitMillis@Deprecated public void setDefaultMaxWaitMillis(long maxWaitMillis) Deprecated.Sets the default value forBaseObjectPoolConfig.getMaxWaitMillis()for each per user pool.- Parameters:
- maxWaitMillis- The default value for- BaseObjectPoolConfig.getMaxWaitMillis()for each per user pool.
 
 - 
setDefaultMinEvictableIdlepublic void setDefaultMinEvictableIdle(java.time.Duration defaultMinEvictableIdleDuration) Sets the default value forBaseObjectPoolConfig.getMinEvictableIdleDuration()for each per user pool.- Parameters:
- defaultMinEvictableIdleDuration- The default value for- BaseObjectPoolConfig.getMinEvictableIdleDuration()for each per user pool.
- Since:
- 2.10.0
 
 - 
setDefaultMinEvictableIdleTimeMillis@Deprecated public void setDefaultMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) Deprecated.Sets the default value forBaseObjectPoolConfig.getMinEvictableIdleDuration()for each per user pool.- Parameters:
- minEvictableIdleTimeMillis- The default value for- BaseObjectPoolConfig.getMinEvictableIdleDuration()for each per user pool.
 
 - 
setDefaultMinIdlepublic void setDefaultMinIdle(int minIdle) Sets the default value forGenericKeyedObjectPoolConfig.getMinIdlePerKey()for each per user pool.- Parameters:
- minIdle- The default value for- GenericKeyedObjectPoolConfig.getMinIdlePerKey()for each per user pool.
 
 - 
setDefaultNumTestsPerEvictionRunpublic void setDefaultNumTestsPerEvictionRun(int numTestsPerEvictionRun) Sets the default value forBaseObjectPoolConfig.getNumTestsPerEvictionRun()for each per user pool.- Parameters:
- numTestsPerEvictionRun- The default value for- BaseObjectPoolConfig.getNumTestsPerEvictionRun()for each per user pool.
 
 - 
setDefaultReadOnlypublic void setDefaultReadOnly(java.lang.Boolean defaultReadOnly) Sets the value of defaultReadOnly, which defines the state of connections handed out from this pool. The value can be changed on the Connection using Connection.setReadOnly(boolean). The default isnullwhich will use the default value for the drive.- Parameters:
- defaultReadOnly- Value to assign to defaultReadOnly.
 
 - 
setDefaultSoftMinEvictableIdlepublic void setDefaultSoftMinEvictableIdle(java.time.Duration defaultSoftMinEvictableIdleDuration) Sets the default value forGenericObjectPool#getSoftMinEvictableIdleTimeMillis()for each per user pool.- Parameters:
- defaultSoftMinEvictableIdleDuration- The default value for- GenericObjectPool#getSoftMinEvictableIdleTimeMillis()for each per user pool.
- Since:
- 2.10.0
 
 - 
setDefaultSoftMinEvictableIdleTimeMillis@Deprecated public void setDefaultSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis) Deprecated.Sets the default value forGenericObjectPool#getSoftMinEvictableIdleTimeMillis()for each per user pool.- Parameters:
- softMinEvictableIdleTimeMillis- The default value for- GenericObjectPool#getSoftMinEvictableIdleTimeMillis()for each per user pool.
 
 - 
setDefaultTestOnBorrowpublic void setDefaultTestOnBorrow(boolean testOnBorrow) Sets the default value forGenericObjectPool#getTestOnBorrow()for each per user pool.- Parameters:
- testOnBorrow- The default value for- GenericObjectPool#getTestOnBorrow()for each per user pool.
 
 - 
setDefaultTestOnCreatepublic void setDefaultTestOnCreate(boolean testOnCreate) Sets the default value forGenericObjectPool#getTestOnCreate()for each per user pool.- Parameters:
- testOnCreate- The default value for- GenericObjectPool#getTestOnCreate()for each per user pool.
 
 - 
setDefaultTestOnReturnpublic void setDefaultTestOnReturn(boolean testOnReturn) Sets the default value forGenericObjectPool#getTestOnReturn()for each per user pool.- Parameters:
- testOnReturn- The default value for- GenericObjectPool#getTestOnReturn()for each per user pool.
 
 - 
setDefaultTestWhileIdlepublic void setDefaultTestWhileIdle(boolean testWhileIdle) Sets the default value forGenericObjectPool#getTestWhileIdle()for each per user pool.- Parameters:
- testWhileIdle- The default value for- GenericObjectPool#getTestWhileIdle()for each per user pool.
 
 - 
setDefaultTimeBetweenEvictionRunsMillis@Deprecated public void setDefaultTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) Deprecated.Sets the default value forBaseGenericObjectPool.getDurationBetweenEvictionRuns()for each per user pool.- Parameters:
- timeBetweenEvictionRunsMillis- The default value for- BaseGenericObjectPool.getDurationBetweenEvictionRuns()for each per user pool.
 
 - 
setDefaultTransactionIsolationpublic void setDefaultTransactionIsolation(int defaultTransactionIsolation) Sets the value of defaultTransactionIsolation, which defines the state of connections handed out from this pool. The value can be changed on the Connection using Connection.setTransactionIsolation(int). The default is JDBC driver dependent.- Parameters:
- defaultTransactionIsolation- Value to assign to defaultTransactionIsolation
 
 - 
setDescriptionpublic void setDescription(java.lang.String description) Sets the description. This property is defined by JDBC as for use with GUI (or other) tools that might deploy the datasource. It serves no internal purpose.- Parameters:
- description- Value to assign to description.
 
 - 
setJndiEnvironmentpublic void setJndiEnvironment(java.lang.String key, java.lang.String value)Sets the value of the given JNDI environment property to be used when instantiating a JNDI InitialContext. This InitialContext is used to locate the back end ConnectionPoolDataSource.- Parameters:
- key- the JNDI environment property to set.
- value- the value assigned to specified JNDI environment property.
 
 - 
setLoginTimeoutpublic void setLoginTimeout(java.time.Duration loginTimeout) Sets the value of loginTimeout.- Parameters:
- loginTimeout- Value to assign to loginTimeout.
- Since:
- 2.10.0
 
 - 
setLoginTimeout@Deprecated public void setLoginTimeout(int loginTimeout) Deprecated.Sets the value of loginTimeout.- Specified by:
- setLoginTimeoutin interface- javax.sql.CommonDataSource
- Specified by:
- setLoginTimeoutin interface- javax.sql.DataSource
- Parameters:
- loginTimeout- Value to assign to loginTimeout.
 
 - 
setLogWriterpublic void setLogWriter(java.io.PrintWriter logWriter) Sets the value of logWriter.- Specified by:
- setLogWriterin interface- javax.sql.CommonDataSource
- Specified by:
- setLogWriterin interface- javax.sql.DataSource
- Parameters:
- logWriter- Value to assign to logWriter.
 
 - 
setMaxConnLifetimepublic void setMaxConnLifetime(java.time.Duration maxConnLifetimeMillis) Sets the maximum permitted lifetime of a connection. A value of zero or less indicates an infinite lifetime. 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.- Parameters:
- maxConnLifetimeMillis- The maximum permitted lifetime of a connection. A value of zero or less indicates an infinite lifetime.
- Since:
- 2.9.0
 
 - 
setMaxConnLifetimeMillis@Deprecated public void setMaxConnLifetimeMillis(long maxConnLifetimeMillis) Deprecated.Sets the maximum permitted lifetime of a connection in milliseconds. A value of zero or less indicates an infinite lifetime. 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.- Parameters:
- maxConnLifetimeMillis- The maximum permitted lifetime of a connection in milliseconds. A value of zero or less indicates an infinite lifetime.
 
 - 
setRollbackAfterValidationpublic void setRollbackAfterValidation(boolean rollbackAfterValidation) Whether a rollback will be issued after executing the SQL query that will be used to validate connections from this pool before returning them to the caller. Default behavior is NOT to issue a rollback. The setting will only have an effect if a validation query is set- Parameters:
- rollbackAfterValidation- new property value
 
 - 
setupDefaultsprotected abstract void setupDefaults(java.sql.Connection connection, java.lang.String userName) throws java.sql.SQLException- Throws:
- java.sql.SQLException
 
 - 
setValidationQuerypublic void setValidationQuery(java.lang.String validationQuery) Sets the SQL query that will be used to validate connections from this pool before returning them to the caller. If specified, this query MUST be an SQL SELECT statement that returns at least one row. If not specified, connections will be validated usingConnection.isValid(int).- Parameters:
- validationQuery- The SQL query that will be used to validate connections from this pool before returning them to the caller.
 
 - 
setValidationQueryTimeoutpublic void setValidationQueryTimeout(java.time.Duration validationQueryTimeoutDuration) Sets the timeout duration before the validation query fails.- Parameters:
- validationQueryTimeoutDuration- The new timeout duration.
 
 - 
setValidationQueryTimeout@Deprecated public void setValidationQueryTimeout(int validationQueryTimeoutSeconds) Deprecated.Sets the timeout in seconds before the validation query fails.- Parameters:
- validationQueryTimeoutSeconds- The new timeout in seconds
 
 - 
testCPDSprotected javax.sql.ConnectionPoolDataSource testCPDS(java.lang.String userName, java.lang.String userPassword) throws javax.naming.NamingException, java.sql.SQLException- Throws:
- javax.naming.NamingException
- java.sql.SQLException
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
- Since:
- 2.6.0
 
 - 
toStringFieldsprotected void toStringFields(java.lang.StringBuilder builder) 
 - 
unwrappublic <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException- Specified by:
- unwrapin interface- java.sql.Wrapper
- Throws:
- java.sql.SQLException
 
 
- 
 
-