This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git
The following commit(s) were added to refs/heads/master by this push: new 6269141 Reformat using updated standard Eclipse format 6269141 is described below commit 6269141ad08dd618701432dd6729f8bc898ec0e2 Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Jul 11 10:08:19 2019 +0100 Reformat using updated standard Eclipse format This is noiser than necessary because I accidentally included some format changes I was experimenting with in the previous commit that addressed line endings. --- .../org/apache/commons/dbcp2/BasicDataSource.java | 1022 +++++++------------- 1 file changed, 347 insertions(+), 675 deletions(-) diff --git a/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java b/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java index 72d4555..6bf8b34 100644 --- a/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java +++ b/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java @@ -54,16 +54,14 @@ import org.apache.commons.pool2.impl.GenericObjectPoolConfig; /** * <p> - * Basic implementation of <code>javax.sql.DataSource</code> that is configured - * via JavaBeans properties. This is not the only way to combine the - * <em>commons-dbcp2</em> and <em>commons-pool2</em> packages, but provides a - * "one stop shopping" solution for basic requirements. + * Basic implementation of <code>javax.sql.DataSource</code> that is configured via JavaBeans properties. This is not + * the only way to combine the <em>commons-dbcp2</em> and <em>commons-pool2</em> packages, but provides a "one stop + * shopping" solution for basic requirements. * </p> * * @since 2.0 */ -public class BasicDataSource - implements DataSource, BasicDataSourceMXBean, MBeanRegistration, AutoCloseable { +public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBeanRegistration, AutoCloseable { /** * @since 2.0 @@ -110,9 +108,8 @@ public class BasicDataSource } } - - protected static void validateConnectionFactory( - final PoolableConnectionFactory connectionFactory) throws Exception { + protected static void validateConnectionFactory(final PoolableConnectionFactory connectionFactory) + throws Exception { PoolableConnection conn = null; PooledObject<PoolableConnection> p = null; try { @@ -139,8 +136,7 @@ public class BasicDataSource private transient Boolean defaultReadOnly; /** - * The default TransactionIsolation state of connections created by this - * pool. + * The default TransactionIsolation state of connections created by this pool. */ private volatile int defaultTransactionIsolation = PoolableConnectionFactory.UNKNOWN_TRANSACTION_ISOLATION; @@ -157,8 +153,8 @@ public class BasicDataSource private volatile String defaultSchema; /** - * The property that controls if the pooled connections cache some state - * rather than query the database for current state to improve performance. + * The property that controls if the pooled connections cache some state rather than query the database for current + * state to improve performance. */ private boolean cacheState = true; @@ -173,167 +169,143 @@ public class BasicDataSource private String driverClassName; /** - * The class loader instance to use to load the JDBC driver. If not - * specified, {@link Class#forName(String)} is used to load the JDBC driver. - * If specified, {@link Class#forName(String, boolean, ClassLoader)} is - * used. + * The class loader instance to use to load the JDBC driver. If not specified, {@link Class#forName(String)} is used + * to load the JDBC driver. If specified, {@link Class#forName(String, boolean, ClassLoader)} is used. */ private ClassLoader driverClassLoader; /** - * True means that borrowObject returns the most recently used ("last in") - * connection in the pool (if there are idle connections available). False - * means that the pool behaves as a FIFO queue - connections are taken from - * the idle instance pool in the order that they are returned to the pool. + * True means that borrowObject returns the most recently used ("last in") connection in the pool (if there are idle + * connections available). False means that the pool behaves as a FIFO queue - connections are taken from the idle + * instance pool in the order that they are returned to the pool. */ private boolean lifo = BaseObjectPoolConfig.DEFAULT_LIFO; /** - * The maximum number of active connections that can be allocated from this - * pool at the same time, or negative for no limit. + * The maximum number of active connections that can be allocated from this pool at the same time, or negative for + * no limit. */ private int maxTotal = GenericObjectPoolConfig.DEFAULT_MAX_TOTAL; /** - * The maximum number of connections that can remain idle in the pool, - * without extra ones being destroyed, or negative for no limit. If maxIdle - * is set too low on heavily loaded systems it is possible you will see - * connections being closed and almost immediately new connections being - * opened. This is a result of the active threads momentarily closing - * connections faster than they are opening them, causing the number of idle - * connections to rise above maxIdle. The best value for maxIdle for heavily - * loaded system will vary but the default is a good starting point. + * The maximum number of connections that can remain idle in the pool, without extra ones being destroyed, or + * negative for no limit. If maxIdle is set too low on heavily loaded systems it is possible you will see + * connections being closed and almost immediately new connections being opened. This is a result of the active + * threads momentarily closing connections faster than they are opening them, causing the number of idle connections + * to rise above maxIdle. The best value for maxIdle for heavily loaded system will vary but the default is a good + * starting point. */ private int maxIdle = GenericObjectPoolConfig.DEFAULT_MAX_IDLE; /** - * The minimum number of active connections that can remain idle in the - * pool, without extra ones being created when the evictor runs, or 0 to - * create none. The pool attempts to ensure that minIdle connections are - * available when the idle object evictor runs. The value of this property - * has no effect unless {@link #timeBetweenEvictionRunsMillis} has a - * positive value. + * The minimum number of active connections that can remain idle in the pool, without extra ones being created when + * the evictor runs, or 0 to create none. The pool attempts to ensure that minIdle connections are available when + * the idle object evictor runs. The value of this property has no effect unless + * {@link #timeBetweenEvictionRunsMillis} has a positive value. */ private int minIdle = GenericObjectPoolConfig.DEFAULT_MIN_IDLE; /** - * The initial number of connections that are created when the pool is - * started. + * The initial number of connections that are created when the pool is started. */ private int initialSize = 0; /** - * The maximum number of milliseconds that the pool will wait (when there - * are no available connections) for a connection to be returned before - * throwing an exception, or <= 0 to wait indefinitely. + * The maximum number of milliseconds that the pool will wait (when there are no available connections) for a + * connection to be returned before throwing an exception, or <= 0 to wait indefinitely. */ private long maxWaitMillis = BaseObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS; /** - * Prepared statement pooling for this pool. When this property is set to - * <code>true</code> both PreparedStatements and CallableStatements are - * pooled. + * Prepared statement pooling for this pool. When this property is set to <code>true</code> both PreparedStatements + * and CallableStatements are pooled. */ private boolean poolPreparedStatements = false; /** * <p> - * The maximum number of open statements that can be allocated from the - * statement pool at the same time, or negative for no limit. Since a - * connection usually only uses one or two statements at a time, this is - * mostly used to help detect resource leaks. + * The maximum number of open statements that can be allocated from the statement pool at the same time, or negative + * for no limit. Since a connection usually only uses one or two statements at a time, this is mostly used to help + * detect resource leaks. * </p> * <p> - * Note: As of version 1.3, CallableStatements (those produced by - * {@link Connection#prepareCall}) are pooled along with PreparedStatements - * (produced by {@link Connection#prepareStatement}) and - * <code>maxOpenPreparedStatements</code> limits the total number of - * prepared or callable statements that may be in use at a given time. + * Note: As of version 1.3, CallableStatements (those produced by {@link Connection#prepareCall}) are pooled along + * with PreparedStatements (produced by {@link Connection#prepareStatement}) and + * <code>maxOpenPreparedStatements</code> limits the total number of prepared or callable statements that may be in + * use at a given time. * </p> */ private int maxOpenPreparedStatements = GenericKeyedObjectPoolConfig.DEFAULT_MAX_TOTAL; /** - * The indication of whether objects will be validated as soon as they have - * been created by the pool. If the object fails to validate, the borrow - * operation that triggered the creation will fail. + * The indication of whether objects will be validated as soon as they have been created by the pool. If the object + * fails to validate, the borrow operation that triggered the creation will fail. */ private boolean testOnCreate = false; /** - * The indication of whether objects will be validated before being borrowed - * from the pool. If the object fails to validate, it will be dropped from - * the pool, and we will attempt to borrow another. + * The indication of whether objects will be validated before being borrowed from the pool. If the object fails to + * validate, it will be dropped from the pool, and we will attempt to borrow another. */ private boolean testOnBorrow = true; /** - * The indication of whether objects will be validated before being returned - * to the pool. + * The indication of whether objects will be validated before being returned to the pool. */ private boolean testOnReturn = false; /** - * The number of milliseconds to sleep between runs of the idle object - * evictor thread. When non-positive, no idle object evictor thread will be - * run. + * The number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, no idle + * object evictor thread will be run. */ private long timeBetweenEvictionRunsMillis = BaseObjectPoolConfig.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS; /** - * The number of objects to examine during each run of the idle object - * evictor thread (if any). + * The number of objects to examine during each run of the idle object evictor thread (if any). */ private int numTestsPerEvictionRun = BaseObjectPoolConfig.DEFAULT_NUM_TESTS_PER_EVICTION_RUN; /** - * The minimum amount of time an object may sit idle in the pool before it - * is eligible for eviction by the idle object evictor (if any). + * The minimum amount of time an object may sit idle in the pool before it is eligible for eviction by the idle + * object evictor (if any). */ private long minEvictableIdleTimeMillis = BaseObjectPoolConfig.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS; /** - * The minimum amount of time a connection may sit idle in the pool before - * it is eligible for eviction by the idle object evictor, with the extra - * condition that at least "minIdle" connections remain in the pool. Note - * that {@code minEvictableIdleTimeMillis} takes precedence over this - * parameter. See {@link #getSoftMinEvictableIdleTimeMillis()}. + * The minimum amount of time a connection may sit idle in the pool before it is eligible for eviction by the idle + * object evictor, with the extra condition that at least "minIdle" connections remain in the pool. Note that + * {@code minEvictableIdleTimeMillis} takes precedence over this parameter. See + * {@link #getSoftMinEvictableIdleTimeMillis()}. */ private long softMinEvictableIdleTimeMillis = BaseObjectPoolConfig.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS; private String evictionPolicyClassName = BaseObjectPoolConfig.DEFAULT_EVICTION_POLICY_CLASS_NAME; /** - * The indication of whether objects will be validated by the idle object - * evictor (if any). If an object fails to validate, it will be dropped from - * the pool. + * The indication of whether objects will be validated by the idle object evictor (if any). If an object fails to + * validate, it will be dropped from the pool. */ private boolean testWhileIdle = false; /** - * The connection password to be passed to our JDBC driver to establish a - * connection. + * The connection password to be passed to our JDBC driver to establish a connection. */ private volatile String password; /** - * The connection URL to be passed to our JDBC driver to establish a - * connection. + * The connection URL to be passed to our JDBC driver to establish a connection. */ private String url; /** - * The connection user name to be passed to our JDBC driver to establish a - * connection. + * The connection user name to be passed to our JDBC driver to establish a connection. */ private String userName; /** - * The SQL query that will be used to validate connections from this pool - * before returning them to the caller. If specified, this query - * <strong>MUST</strong> be an SQL SELECT statement that returns at least - * one row. If not specified, {@link Connection#isValid(int)} will be used - * to validate connections. + * The SQL query that will be used to validate connections from this pool before returning them to the caller. If + * specified, this query <strong>MUST</strong> be an SQL SELECT statement that returns at least one row. If not + * specified, {@link Connection#isValid(int)} will be used to validate connections. */ private volatile String validationQuery; @@ -343,17 +315,15 @@ public class BasicDataSource private volatile int validationQueryTimeoutSeconds = -1; /** - * The fully qualified Java class name of a {@link ConnectionFactory} - * implementation. + * The fully qualified Java class name of a {@link ConnectionFactory} implementation. */ private String connectionFactoryClassName; /** * These SQL statements run once after a Connection is created. * <p> - * This property can be used for example to run ALTER SESSION SET - * NLS_SORT=XCYECH in an Oracle Database only once after connection - * creation. + * This property can be used for example to run ALTER SESSION SET NLS_SORT=XCYECH in an Oracle Database only once + * after connection creation. * </p> */ private volatile List<String> connectionInitSqls; @@ -383,17 +353,15 @@ public class BasicDataSource private volatile GenericObjectPool<PoolableConnection> connectionPool; /** - * The connection properties that will be sent to our JDBC driver when - * establishing new connections. <strong>NOTE</strong> - The "user" and - * "password" properties will be passed explicitly, so they do not need to - * be included here. + * The connection properties that will be sent to our JDBC driver when establishing new connections. + * <strong>NOTE</strong> - The "user" and "password" properties will be passed explicitly, so they do not need to be + * included here. */ private Properties connectionProperties = new Properties(); /** - * The data source we will use to manage connections. This object should be - * acquired <strong>ONLY</strong> by calls to the - * <code>createDataSource()</code> method. + * The data source we will use to manage connections. This object should be acquired <strong>ONLY</strong> by calls + * to the <code>createDataSource()</code> method. */ private volatile DataSource dataSource; @@ -412,40 +380,35 @@ public class BasicDataSource */ private ObjectNameWrapper registeredJmxObjectName; - /** - * Adds a custom connection property to the set that will be passed to our - * JDBC driver. This <strong>MUST</strong> be called before the first - * connection is retrieved (along with all the other configuration property - * setters). Calls to this method after the connection pool has been - * initialized have no effect. + * Adds a custom connection property to the set that will be passed to our JDBC driver. This <strong>MUST</strong> + * be called before the first connection is retrieved (along with all the other configuration property setters). + * Calls to this method after the connection pool has been initialized have no effect. * - * @param name Name of the custom connection property + * @param name Name of the custom connection property * @param value Value of the custom connection property */ public void addConnectionProperty(final String name, final String value) { connectionProperties.put(name, value); } - /** * <p> - * Closes and releases all idle connections that are currently stored in the - * connection pool associated with this data source. + * Closes and releases all idle connections that are currently stored in the connection pool associated with this + * data source. * </p> * <p> - * Connections that are checked out to clients when this method is invoked - * are not affected. When client applications subsequently invoke - * {@link Connection#close()} to return these connections to the pool, the + * Connections that are checked out to clients when this method is invoked are not affected. When client + * applications subsequently invoke {@link Connection#close()} to return these connections to the pool, the * underlying JDBC connections are closed. * </p> * <p> - * Attempts to acquire connections using {@link #getConnection()} after this - * method has been invoked result in SQLExceptions. + * Attempts to acquire connections using {@link #getConnection()} after this method has been invoked result in + * SQLExceptions. * </p> * <p> - * This method is idempotent - i.e., closing an already closed - * BasicDataSource has no effect and does not generate exceptions. + * This method is idempotent - i.e., closing an already closed BasicDataSource has no effect and does not generate + * exceptions. * </p> * * @throws SQLException if an error occurs closing idle connections @@ -471,10 +434,8 @@ public class BasicDataSource } } - /** - * Closes the connection pool, silently swallowing any exception that - * occurs. + * Closes the connection pool, silently swallowing any exception that occurs. */ private void closeConnectionPool() { final GenericObjectPool<?> oldPool = connectionPool; @@ -488,22 +449,16 @@ public class BasicDataSource } } - /** - * Creates a JDBC connection factory for this datasource. The JDBC driver is - * loaded using the following algorithm: + * Creates a JDBC connection factory for this datasource. The JDBC driver is loaded using the following algorithm: * <ol> - * <li>If a Driver instance has been specified via - * {@link #setDriver(Driver)} use it</li> - * <li>If no Driver instance was specified and {@link #driverClassName} is - * specified that class is loaded using the {@link ClassLoader} of this - * class or, if {@link #driverClassLoader} is set, {@link #driverClassName} - * is loaded with the specified {@link ClassLoader}.</li> - * <li>If {@link #driverClassName} is specified and the previous attempt - * fails, the class is loaded using the context class loader of the current - * thread.</li> - * <li>If a driver still isn't loaded one is loaded via the - * {@link DriverManager} using the specified {@link #url}. + * <li>If a Driver instance has been specified via {@link #setDriver(Driver)} use it</li> + * <li>If no Driver instance was specified and {@link #driverClassName} is specified that class is loaded using the + * {@link ClassLoader} of this class or, if {@link #driverClassLoader} is set, {@link #driverClassName} is loaded + * with the specified {@link ClassLoader}.</li> + * <li>If {@link #driverClassName} is specified and the previous attempt fails, the class is loaded using the + * context class loader of the current thread.</li> + * <li>If a driver still isn't loaded one is loaded via the {@link DriverManager} using the specified {@link #url}. * </ol> * This method exists so subclasses can replace the implementation class. * @@ -526,12 +481,10 @@ public class BasicDataSource driverFromCCL = Class.forName(driverClassName, true, driverClassLoader); } } catch (final ClassNotFoundException cnfe) { - driverFromCCL = Thread.currentThread().getContextClassLoader() - .loadClass(driverClassName); + driverFromCCL = Thread.currentThread().getContextClassLoader().loadClass(driverClassName); } } catch (final Exception t) { - final String message = "Cannot load JDBC driver class '" + driverClassName + - "'"; + final String message = "Cannot load JDBC driver class '" + driverClassName + "'"; logWriter.println(message); t.printStackTrace(logWriter); throw new SQLException(message, t); @@ -552,9 +505,8 @@ public class BasicDataSource } } } catch (final Exception t) { - final String message = "Cannot create JDBC driver of class '" + - (driverClassName != null ? driverClassName : "") + "' for connect URL '" + - url + "'"; + final String message = "Cannot create JDBC driver of class '" + + (driverClassName != null ? driverClassName : "") + "' for connect URL '" + url + "'"; logWriter.println(message); t.printStackTrace(logWriter); throw new SQLException(message, t); @@ -579,20 +531,16 @@ public class BasicDataSource return createConnectionFactory(driverToUse); } - /** - * Creates a connection pool for this datasource. This method only exists so - * subclasses can replace the implementation class. + * Creates a connection pool for this datasource. This method only exists so subclasses can replace the + * implementation class. * <p> - * This implementation configures all pool properties other than - * timeBetweenEvictionRunsMillis. Setting that property is deferred to - * {@link #startPoolMaintenance()}, since setting - * timeBetweenEvictionRunsMillis to a positive value causes - * {@link GenericObjectPool}'s eviction timer to be started. + * This implementation configures all pool properties other than timeBetweenEvictionRunsMillis. Setting that + * property is deferred to {@link #startPoolMaintenance()}, since setting timeBetweenEvictionRunsMillis to a + * positive value causes {@link GenericObjectPool}'s eviction timer to be started. * </p> * - * @param factory The factory to use to create new connections for this - * pool. + * @param factory The factory to use to create new connections for this pool. */ protected void createConnectionPool(final PoolableConnectionFactory factory) { // Create an object pool to contain our active connections @@ -600,8 +548,7 @@ public class BasicDataSource updateJmxName(config); // Disable JMX on the underlying pool if the DS is not registered: config.setJmxEnabled(registeredJmxObjectName != null); - final GenericObjectPool<PoolableConnection> gop = createObjectPool(factory, config, - abandonedConfig); + final GenericObjectPool<PoolableConnection> gop = createObjectPool(factory, config, abandonedConfig); gop.setMaxTotal(maxTotal); gop.setMaxIdle(maxIdle); gop.setMinIdle(minIdle); @@ -620,15 +567,12 @@ public class BasicDataSource connectionPool = gop; } - /** * <p> - * Creates (if necessary) and return the internal data source we are using - * to manage our connections. + * Creates (if necessary) and return the internal data source we are using to manage our connections. * </p> * - * @return The current internal DataSource or a newly created instance if it - * has not yet been created. + * @return The current internal DataSource or a newly created instance if it has not yet been created. * @throws SQLException if the object pool cannot be created. */ protected DataSource createDataSource() throws SQLException { @@ -656,8 +600,7 @@ public class BasicDataSource boolean success = false; PoolableConnectionFactory poolableConnectionFactory; try { - poolableConnectionFactory = createPoolableConnectionFactory( - driverConnectionFactory); + poolableConnectionFactory = createPoolableConnectionFactory(driverConnectionFactory); poolableConnectionFactory.setPoolStatements(poolPreparedStatements); poolableConnectionFactory.setMaxOpenPreparedStatements(maxOpenPreparedStatements); success = true; @@ -712,10 +655,9 @@ public class BasicDataSource } } - /** - * Creates the actual data source instance. This method only exists so that - * subclasses can replace the implementation class. + * Creates the actual data source instance. This method only exists so that subclasses can replace the + * implementation class. * * @throws SQLException if unable to create a datasource instance * @@ -727,23 +669,19 @@ public class BasicDataSource return pds; } - /** - * Creates an object pool used to provide pooling support for - * {@link Connection JDBC connections}. + * Creates an object pool used to provide pooling support for {@link Connection JDBC connections}. * - * @param factory the object factory - * @param poolConfig the object pool configuration + * @param factory the object factory + * @param poolConfig the object pool configuration * @param abandonedConfig the abandoned objects configuration * @return a non-null instance */ - protected GenericObjectPool<PoolableConnection> createObjectPool( - final PoolableConnectionFactory factory, - final GenericObjectPoolConfig<PoolableConnection> poolConfig, - final AbandonedConfig abandonedConfig) { + protected GenericObjectPool<PoolableConnection> createObjectPool(final PoolableConnectionFactory factory, + final GenericObjectPoolConfig<PoolableConnection> poolConfig, final AbandonedConfig abandonedConfig) { GenericObjectPool<PoolableConnection> gop; - if (abandonedConfig != null && (abandonedConfig.getRemoveAbandonedOnBorrow() || - abandonedConfig.getRemoveAbandonedOnMaintenance())) { + if (abandonedConfig != null && (abandonedConfig.getRemoveAbandonedOnBorrow() + || abandonedConfig.getRemoveAbandonedOnMaintenance())) { gop = new GenericObjectPool<>(factory, poolConfig, abandonedConfig); } else { gop = new GenericObjectPool<>(factory, poolConfig); @@ -751,21 +689,17 @@ public class BasicDataSource return gop; } - /** - * Creates the PoolableConnectionFactory and attaches it to the connection - * pool. This method only exists so subclasses can replace the default - * implementation. + * Creates the PoolableConnectionFactory and attaches it to the connection pool. This method only exists so + * subclasses can replace the default implementation. * * @param driverConnectionFactory JDBC connection factory - * @throws SQLException if an error occurs creating the - * PoolableConnectionFactory + * @throws SQLException if an error occurs creating the PoolableConnectionFactory * - * @return A new PoolableConnectionFactory configured with the current - * configuration of this BasicDataSource + * @return A new PoolableConnectionFactory configured with the current configuration of this BasicDataSource */ - protected PoolableConnectionFactory createPoolableConnectionFactory( - final ConnectionFactory driverConnectionFactory) throws SQLException { + protected PoolableConnectionFactory createPoolableConnectionFactory(final ConnectionFactory driverConnectionFactory) + throws SQLException { PoolableConnectionFactory connectionFactory = null; try { connectionFactory = new PoolableConnectionFactory(driverConnectionFactory, @@ -791,19 +725,15 @@ public class BasicDataSource } catch (final RuntimeException e) { throw e; } catch (final Exception e) { - throw new SQLException( - "Cannot create PoolableConnectionFactory (" + e.getMessage() + ")", e); + throw new SQLException("Cannot create PoolableConnectionFactory (" + e.getMessage() + ")", e); } return connectionFactory; } - /** - * Gets the print writer used by this configuration to log information on - * abandoned objects. + * Gets the print writer used by this configuration to log information on abandoned objects. * - * @return The print writer used by this configuration to log information on - * abandoned objects. + * @return The print writer used by this configuration to log information on abandoned objects. */ public PrintWriter getAbandonedLogWriter() { if (abandonedConfig != null) { @@ -812,13 +742,10 @@ public class BasicDataSource return null; } - /** - * If the connection pool implements - * {@link org.apache.commons.pool2.UsageTracking UsageTracking}, should the - * connection pool record a stack trace every time a method is called on a - * pooled connection and retain the most recent stack trace to aid debugging - * of abandoned connections? + * If the connection pool implements {@link org.apache.commons.pool2.UsageTracking UsageTracking}, should the + * connection pool record a stack trace every time a method is called on a pooled connection and retain the most + * recent stack trace to aid debugging of abandoned connections? * * @return <code>true</code> if usage tracking is enabled */ @@ -830,22 +757,17 @@ public class BasicDataSource return false; } - /** - * Returns the value of the flag that controls whether or not connections - * being returned to the pool will be checked and configured with - * {@link Connection#setAutoCommit(boolean) Connection.setAutoCommit(true)} - * if the auto commit setting is {@code false} when the connection is - * returned. It is <code>true</code> by default. + * Returns the value of the flag that controls whether or not connections being returned to the pool will be checked + * and configured with {@link Connection#setAutoCommit(boolean) Connection.setAutoCommit(true)} if the auto commit + * setting is {@code false} when the connection is returned. It is <code>true</code> by default. * - * @return Whether or not connections being returned to the pool will be - * checked and configured with auto-commit. + * @return Whether or not connections being returned to the pool will be checked and configured with auto-commit. */ public boolean getAutoCommitOnReturn() { return autoCommitOnReturn; } - /** * Returns the state caching flag. * @@ -856,7 +778,6 @@ public class BasicDataSource return cacheState; } - /** * Creates (if necessary) and return a connection to the database. * @@ -880,7 +801,6 @@ public class BasicDataSource return createDataSource().getConnection(); } - /** * <strong>BasicDataSource does NOT support this method.</strong> * @@ -888,7 +808,7 @@ public class BasicDataSource * @param pass The database user's password * * @throws UnsupportedOperationException always thrown. - * @throws SQLException if a database access error occurs + * @throws SQLException if a database access error occurs * @return nothing - always throws UnsupportedOperationException */ @Override @@ -898,11 +818,9 @@ public class BasicDataSource throw new UnsupportedOperationException("Not supported by BasicDataSource"); } - /** - * Returns the list of SQL statements executed when a physical connection is - * first created. Returns an empty list if there are no initialization - * statements configured. + * Returns the list of SQL statements executed when a physical connection is first created. Returns an empty list if + * there are no initialization statements configured. * * @return initialization SQL statements */ @@ -914,10 +832,8 @@ public class BasicDataSource return result; } - /** - * Provides the same data as {@link #getConnectionInitSqls()} but in an - * array so it is accessible via JMX. + * Provides the same data as {@link #getConnectionInitSqls()} but in an array so it is accessible via JMX. */ @Override public String[] getConnectionInitSqlsAsArray() { @@ -925,18 +841,15 @@ public class BasicDataSource return result.toArray(new String[result.size()]); } - protected GenericObjectPool<PoolableConnection> getConnectionPool() { return connectionPool; } - // For unit testing Properties getConnectionProperties() { return connectionProperties; } - /** * Returns the default auto-commit property. * @@ -947,7 +860,6 @@ public class BasicDataSource return defaultAutoCommit; } - /** * Returns the default catalog. * @@ -958,11 +870,9 @@ public class BasicDataSource return this.defaultCatalog; } - /** - * Gets the default query timeout that will be used for - * {@link java.sql.Statement Statement}s created from this connection. - * <code>null</code> means that the driver default will be used. + * Gets the default query timeout that will be used for {@link java.sql.Statement Statement}s created from this + * connection. <code>null</code> means that the driver default will be used. * * @return The default query timeout in seconds. */ @@ -970,7 +880,6 @@ public class BasicDataSource return defaultQueryTimeoutSeconds; } - /** * Returns the default readOnly property. * @@ -981,7 +890,6 @@ public class BasicDataSource return defaultReadOnly; } - /** * Returns the default schema. * @@ -993,7 +901,6 @@ public class BasicDataSource return this.defaultSchema; } - /** * Returns the default transaction isolation state of returned connections. * @@ -1005,7 +912,6 @@ public class BasicDataSource return this.defaultTransactionIsolation; } - /** * Returns the set of SQL_STATE codes considered to signal fatal conditions. * @@ -1021,10 +927,8 @@ public class BasicDataSource return result; } - /** - * Provides the same data as {@link #getDisconnectionSqlCodes} but in an - * array so it is accessible via JMX. + * Provides the same data as {@link #getDisconnectionSqlCodes} but in an array so it is accessible via JMX. * * @since 2.1 */ @@ -1034,14 +938,11 @@ public class BasicDataSource return result.toArray(new String[result.size()]); } - /** * Returns the JDBC Driver that has been configured for use by this pool. * <p> - * Note: This getter only returns the last value set by a call to - * {@link #setDriver(Driver)}. It does not return any driver instance that - * may have been created from the value set via - * {@link #setDriverClassName(String)}. + * Note: This getter only returns the last value set by a call to {@link #setDriver(Driver)}. It does not return any + * driver instance that may have been created from the value set via {@link #setDriverClassName(String)}. * </p> * * @return the JDBC Driver that has been configured for use by this pool @@ -1050,15 +951,12 @@ public class BasicDataSource return driver; } - /** - * Returns the class loader specified for loading the JDBC driver. Returns - * <code>null</code> if no class loader has been explicitly specified. + * Returns the class loader specified for loading the JDBC driver. Returns <code>null</code> if no class loader has + * been explicitly specified. * <p> - * Note: This getter only returns the last value set by a call to - * {@link #setDriverClassLoader(ClassLoader)}. It does not return the class - * loader of any driver that may have been set via - * {@link #setDriver(Driver)}. + * Note: This getter only returns the last value set by a call to {@link #setDriverClassLoader(ClassLoader)}. It + * does not return the class loader of any driver that may have been set via {@link #setDriver(Driver)}. * </p> * * @return The class loader specified for loading the JDBC driver. @@ -1067,13 +965,11 @@ public class BasicDataSource return this.driverClassLoader; } - /** * Returns the JDBC driver class name. * <p> - * Note: This getter only returns the last value set by a call to - * {@link #setDriverClassName(String)}. It does not return the class name of - * any driver that may have been set via {@link #setDriver(Driver)}. + * Note: This getter only returns the last value set by a call to {@link #setDriverClassName(String)}. It does not + * return the class name of any driver that may have been set via {@link #setDriver(Driver)}. * </p> * * @return the JDBC driver class name @@ -1083,33 +979,25 @@ public class BasicDataSource return this.driverClassName; } - /** - * Returns the ConnectionFactoryClassName that has been configured for use - * by this pool. + * Returns the ConnectionFactoryClassName that has been configured for use by this pool. * <p> - * Note: This getter only returns the last value set by a call to - * {@link #setConnectionFactoryClassName(String)}. + * Note: This getter only returns the last value set by a call to {@link #setConnectionFactoryClassName(String)}. * </p> * - * @return the ConnectionFactoryClassName that has been configured for use - * by this pool. + * @return the ConnectionFactoryClassName that has been configured for use by this pool. * @since 2.7.0 */ public String getConnectionFactoryClassName() { return this.connectionFactoryClassName; } - /** - * Returns the value of the flag that controls whether or not connections - * being returned to the pool will be checked and configured with - * {@link Connection#setAutoCommit(boolean) Connection.setAutoCommit(true)} - * if the auto commit setting is {@code false} when the connection is - * returned. It is <code>true</code> by default. + * Returns the value of the flag that controls whether or not connections being returned to the pool will be checked + * and configured with {@link Connection#setAutoCommit(boolean) Connection.setAutoCommit(true)} if the auto commit + * setting is {@code false} when the connection is returned. It is <code>true</code> by default. * - * @return Whether or not connections being returned to the pool will be - * checked and configured with auto-commit. + * @return Whether or not connections being returned to the pool will be checked and configured with auto-commit. * @deprecated Use {@link #getAutoCommitOnReturn()}. */ @Deprecated @@ -1117,25 +1005,20 @@ public class BasicDataSource return autoCommitOnReturn; } - /** * Gets the EvictionPolicy implementation in use with this connection pool. * - * @return The EvictionPolicy implementation in use with this connection - * pool. + * @return The EvictionPolicy implementation in use with this connection pool. */ public synchronized String getEvictionPolicyClassName() { return evictionPolicyClassName; } - /** - * True means that validation will fail immediately for connections that - * have previously thrown SQLExceptions with SQL_STATE indicating fatal - * disconnection errors. + * True means that validation will fail immediately for connections that have previously thrown SQLExceptions with + * SQL_STATE indicating fatal disconnection errors. * - * @return true if connections created by this datasource will fast fail - * validation. + * @return true if connections created by this datasource will fast fail validation. * @see #setDisconnectionSqlCodes(Collection) * @since 2.1 */ @@ -1144,7 +1027,6 @@ public class BasicDataSource return fastFailValidation; } - /** * Returns the initial size of the connection pool. * @@ -1155,10 +1037,9 @@ public class BasicDataSource return this.initialSize; } - /** - * Returns the JMX name that has been requested for this DataSource. If the - * requested name is not valid, an alternative may be chosen. + * Returns the JMX name that has been requested for this DataSource. If the requested name is not valid, an + * alternative may be chosen. * * @return The JMX name that has been requested for this DataSource. */ @@ -1166,7 +1047,6 @@ public class BasicDataSource return jmxName; } - /** * Returns the LIFO property. * @@ -1177,19 +1057,16 @@ public class BasicDataSource return this.lifo; } - /** * <p> - * Flag to log stack traces for application code which abandoned a Statement - * or Connection. + * Flag to log stack traces for application code which abandoned a Statement or Connection. * </p> * <p> * Defaults to false. * </p> * <p> - * Logging of abandoned Statements and Connections adds overhead for every - * Connection open or new Statement because a stack trace has to be - * generated. + * Logging of abandoned Statements and Connections adds overhead for every Connection open or new Statement because + * a stack trace has to be generated. * </p> */ @Override @@ -1200,12 +1077,9 @@ public class BasicDataSource return false; } - /** - * When {@link #getMaxConnLifetimeMillis()} is set to limit connection - * lifetime, this property determines whether or not log messages are - * generated when the pool closes connections due to maximum lifetime - * exceeded. + * When {@link #getMaxConnLifetimeMillis()} is set to limit connection lifetime, this property determines whether or + * not log messages are generated when the pool closes connections due to maximum lifetime exceeded. * * @since 2.1 */ @@ -1214,7 +1088,6 @@ public class BasicDataSource return logExpiredConnections; } - /** * <strong>BasicDataSource does NOT support this method.</strong> * @@ -1222,13 +1095,12 @@ public class BasicDataSource * Returns the login timeout (in seconds) for connecting to the database. * </p> * <p> - * Calls {@link #createDataSource()}, so has the side effect of initializing - * the connection pool. + * Calls {@link #createDataSource()}, so has the side effect of initializing the connection pool. * </p> * - * @throws SQLException if a database access error occurs - * @throws UnsupportedOperationException If the DataSource implementation - * does not support the login timeout feature. + * @throws SQLException if a database access error occurs + * @throws UnsupportedOperationException If the DataSource implementation does not support the login timeout + * feature. * @return login timeout in seconds */ @Override @@ -1238,14 +1110,12 @@ public class BasicDataSource throw new UnsupportedOperationException("Not supported by BasicDataSource"); } - /** * <p> * Returns the log writer being used by this data source. * </p> * <p> - * Calls {@link #createDataSource()}, so has the side effect of initializing - * the connection pool. + * Calls {@link #createDataSource()}, so has the side effect of initializing the connection pool. * </p> * * @throws SQLException if a database access error occurs @@ -1256,21 +1126,19 @@ public class BasicDataSource return createDataSource().getLogWriter(); } - /** - * Returns 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. */ @Override public long getMaxConnLifetimeMillis() { return maxConnLifetimeMillis; } - /** * <p> - * Returns the maximum number of connections that can remain idle in the - * pool. Excess idle connections are destroyed on return to the pool. + * Returns the maximum number of connections that can remain idle in the pool. Excess idle connections are destroyed + * on return to the pool. * </p> * <p> * A negative value indicates that there is no limit @@ -1283,7 +1151,6 @@ public class BasicDataSource return this.maxIdle; } - /** * Gets the value of the <code>maxOpenPreparedStatements</code> property. * @@ -1294,11 +1161,9 @@ public class BasicDataSource return this.maxOpenPreparedStatements; } - /** * <p> - * Returns the maximum number of active connections that can be allocated at - * the same time. + * Returns the maximum number of active connections that can be allocated at the same time. * </p> * <p> * A negative number means that there is no limit. @@ -1311,11 +1176,9 @@ public class BasicDataSource return this.maxTotal; } - /** - * 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. + * 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. * * @return the maxWaitMillis property value */ @@ -1324,7 +1187,6 @@ public class BasicDataSource return this.maxWaitMillis; } - /** * Returns the {@link #minEvictableIdleTimeMillis} property. * @@ -1336,11 +1198,9 @@ public class BasicDataSource return this.minEvictableIdleTimeMillis; } - /** - * Returns the minimum number of idle connections in the pool. The pool - * attempts to ensure that minIdle connections are available when the idle - * object evictor runs. The value of this property has no effect unless + * Returns the minimum number of idle connections in the pool. The pool attempts to ensure that minIdle connections + * are available when the idle object evictor runs. The value of this property has no effect unless * {@link #timeBetweenEvictionRunsMillis} has a positive value. * * @return the minimum number of idle connections @@ -1351,10 +1211,8 @@ public class BasicDataSource return this.minIdle; } - /** - * [Read Only] The current number of active connections that have been - * allocated from this data source. + * [Read Only] The current number of active connections that have been allocated from this data source. * * @return the current number of active connections */ @@ -1368,10 +1226,8 @@ public class BasicDataSource return 0; } - /** - * [Read Only] The current number of idle connections that are waiting to be - * allocated from this data source. + * [Read Only] The current number of idle connections that are waiting to be allocated from this data source. * * @return the current number of idle connections */ @@ -1385,7 +1241,6 @@ public class BasicDataSource return 0; } - /** * Returns the value of the {@link #numTestsPerEvictionRun} property. * @@ -1397,13 +1252,11 @@ public class BasicDataSource return this.numTestsPerEvictionRun; } - @Override public Logger getParentLogger() throws SQLFeatureNotSupportedException { throw new SQLFeatureNotSupportedException(); } - /** * Returns the password passed to the JDBC driver to establish connections. * @@ -1414,29 +1267,24 @@ public class BasicDataSource return this.password; } - protected ObjectName getRegisteredJmxName() { return ObjectNameWrapper.unwrap(registeredJmxObjectName); } - /** * <p> - * Flag to remove abandoned connections if they exceed the - * removeAbandonedTimeout when borrowObject is invoked. + * Flag to remove abandoned connections if they exceed the removeAbandonedTimeout when borrowObject is invoked. * </p> * <p> * The default value is false. * </p> * <p> - * If set to true a connection is considered abandoned and eligible for - * removal if it has not been used for more than - * {@link #getRemoveAbandonedTimeout() removeAbandonedTimeout} seconds. + * If set to true a connection is considered abandoned and eligible for removal if it has not been used for more + * than {@link #getRemoveAbandonedTimeout() removeAbandonedTimeout} seconds. * </p> * <p> - * Abandoned connections are identified and removed when - * {@link #getConnection()} is invoked and all of the following conditions - * hold: + * Abandoned connections are identified and removed when {@link #getConnection()} is invoked and all of the + * following conditions hold: * </p> * <ul> * <li>{@link #getRemoveAbandonedOnBorrow()}</li> @@ -1454,11 +1302,9 @@ public class BasicDataSource return false; } - /** * <p> - * Flag to remove abandoned connections if they exceed the - * removeAbandonedTimeout during pool maintenance. + * Flag to remove abandoned connections if they exceed the removeAbandonedTimeout during pool maintenance. * </p> * * <p> @@ -1466,9 +1312,8 @@ public class BasicDataSource * </p> * * <p> - * If set to true a connection is considered abandoned and eligible for - * removal if it has not been used for more than - * {@link #getRemoveAbandonedTimeout() removeAbandonedTimeout} seconds. + * If set to true a connection is considered abandoned and eligible for removal if it has not been used for more + * than {@link #getRemoveAbandonedTimeout() removeAbandonedTimeout} seconds. * </p> * * @see #getRemoveAbandonedTimeout() @@ -1481,25 +1326,21 @@ public class BasicDataSource return false; } - /** * <p> * Timeout in seconds before an abandoned connection can be removed. * </p> * <p> - * Creating a Statement, PreparedStatement or CallableStatement or using one - * of these to execute a query (using one of the execute methods) resets the - * lastUsed property of the parent connection. + * Creating a Statement, PreparedStatement or CallableStatement or using one of these to execute a query (using one + * of the execute methods) resets the lastUsed property of the parent connection. * </p> * <p> * Abandoned connection cleanup happens when: * </p> * <ul> - * <li>{@link #getRemoveAbandonedOnBorrow()} or - * {@link #getRemoveAbandonedOnMaintenance()} = true</li> + * <li>{@link #getRemoveAbandonedOnBorrow()} or {@link #getRemoveAbandonedOnMaintenance()} = true</li> * <li>{@link #getNumIdle() numIdle} < 2</li> - * <li>{@link #getNumActive() numActive} > {@link #getMaxTotal() - * maxTotal} - 3</li> + * <li>{@link #getNumActive() numActive} > {@link #getMaxTotal() maxTotal} - 3</li> * </ul> * <p> * The default value is 300 seconds. @@ -1513,48 +1354,38 @@ public class BasicDataSource return 300; } - /** - * Gets the current value of the flag that controls whether a connection - * will be rolled back when it is returned to the pool if auto commit is not - * enabled and the connection is not read only. + * Gets the current value of the flag that controls whether a connection will be rolled back when it is returned to + * the pool if auto commit is not enabled and the connection is not read only. * - * @return whether a connection will be rolled back when it is returned to - * the pool. + * @return whether a connection will be rolled back when it is returned to the pool. */ public boolean getRollbackOnReturn() { return rollbackOnReturn; } - /** * <p> - * Returns the minimum amount of time a connection may sit idle in the pool - * before it is eligible for eviction by the idle object evictor, with the - * extra condition that at least "minIdle" connections remain in the pool. + * Returns the minimum amount of time a connection may sit idle in the pool before it is eligible for eviction by + * the idle object evictor, with the extra condition that at least "minIdle" connections remain in the pool. * </p> * * <p> - * When {@link #getMinEvictableIdleTimeMillis() minEvictableIdleTimeMillis} - * is set to a positive value, minEvictableIdleTimeMillis is examined first - * by the idle connection evictor - i.e. when idle connections are visited - * by the evictor, idle time is first compared against - * {@code minEvictableIdleTimeMillis} (without considering the number of - * idle connections in the pool) and then against - * {@code softMinEvictableIdleTimeMillis}, including the {@code minIdle}, - * constraint. + * When {@link #getMinEvictableIdleTimeMillis() minEvictableIdleTimeMillis} is set to a positive value, + * minEvictableIdleTimeMillis is examined first by the idle connection evictor - i.e. when idle connections are + * visited by the evictor, idle time is first compared against {@code minEvictableIdleTimeMillis} (without + * considering the number of idle connections in the pool) and then against {@code softMinEvictableIdleTimeMillis}, + * including the {@code minIdle}, constraint. * </p> * - * @return minimum amount of time a connection may sit idle in the pool - * before it is eligible for eviction, assuming there are minIdle - * idle connections in the pool + * @return minimum amount of time a connection may sit idle in the pool before it is eligible for eviction, assuming + * there are minIdle idle connections in the pool */ @Override public synchronized long getSoftMinEvictableIdleTimeMillis() { return softMinEvictableIdleTimeMillis; } - /** * Returns the {@link #testOnBorrow} property. * @@ -1567,12 +1398,10 @@ public class BasicDataSource return this.testOnBorrow; } - /** * Returns the {@link #testOnCreate} property. * - * @return true if objects are validated immediately after they are created - * by the pool + * @return true if objects are validated immediately after they are created by the pool * @see #testOnCreate */ @Override @@ -1580,7 +1409,6 @@ public class BasicDataSource return this.testOnCreate; } - /** * Returns the value of the {@link #testOnReturn} property. * @@ -1591,7 +1419,6 @@ public class BasicDataSource return this.testOnReturn; } - /** * Returns the value of the {@link #testWhileIdle} property. * @@ -1603,7 +1430,6 @@ public class BasicDataSource return this.testWhileIdle; } - /** * Returns the value of the {@link #timeBetweenEvictionRunsMillis} property. * @@ -1615,34 +1441,28 @@ public class BasicDataSource return this.timeBetweenEvictionRunsMillis; } - /** * Returns the JDBC connection {@link #url} property. * - * @return the {@link #url} passed to the JDBC driver to establish - * connections + * @return the {@link #url} passed to the JDBC driver to establish connections */ @Override public synchronized String getUrl() { return this.url; } - /** * Returns the JDBC connection {@link #userName} property. * - * @return the {@link #userName} passed to the JDBC driver to establish - * connections + * @return the {@link #userName} passed to the JDBC driver to establish connections */ @Override public String getUsername() { return this.userName; } - /** - * Returns the validation query used to validate connections before - * returning them. + * Returns the validation query used to validate connections before returning them. * * @return the SQL validation query * @see #validationQuery @@ -1652,7 +1472,6 @@ public class BasicDataSource return this.validationQuery; } - /** * Returns the validation query timeout. * @@ -1663,10 +1482,9 @@ public class BasicDataSource return validationQueryTimeoutSeconds; } - /** - * Manually invalidates a connection, effectively requesting the pool to try - * to close it, remove it from the pool and reclaim pool capacity. + * Manually invalidates a connection, effectively requesting the pool to try to close it, remove it from the pool + * and reclaim pool capacity. * * @param connection The Connection to invalidate. * @@ -1678,8 +1496,7 @@ public class BasicDataSource return; } if (connectionPool == null) { - throw new IllegalStateException( - "Cannot invalidate connection: ConnectionPool is null."); + throw new IllegalStateException("Cannot invalidate connection: ConnectionPool is null."); } final PoolableConnection poolableConnection; @@ -1690,19 +1507,16 @@ public class BasicDataSource "Cannot invalidate connection: Connection is not a poolable connection."); } } catch (final SQLException e) { - throw new IllegalStateException( - "Cannot invalidate connection: Unwrapping poolable connection failed.", e); + throw new IllegalStateException("Cannot invalidate connection: Unwrapping poolable connection failed.", e); } try { connectionPool.invalidateObject(poolableConnection); } catch (final Exception e) { - throw new IllegalStateException("Invalidating connection threw unexpected exception", - e); + throw new IllegalStateException("Invalidating connection threw unexpected exception", e); } } - /** * Manually evicts idle connections. * @@ -1715,22 +1529,18 @@ public class BasicDataSource } } - /** * Returns the value of the accessToUnderlyingConnectionAllowed property. * - * @return true if access to the underlying connection is allowed, false - * otherwise. + * @return true if access to the underlying connection is allowed, false otherwise. */ @Override public synchronized boolean isAccessToUnderlyingConnectionAllowed() { return this.accessToUnderlyingConnectionAllowed; } - /** - * If true, this data source is closed and no more connections can be - * retrieved from this datasource. + * If true, this data source is closed and no more connections can be retrieved from this datasource. * * @return true, if the data source is closed; false otherwise */ @@ -1739,19 +1549,16 @@ public class BasicDataSource return closed; } - /** * Delegates in a null-safe manner to {@link String#isEmpty()}. * * @param value the string to test, may be null. - * @return boolean false if value is null, otherwise - * {@link String#isEmpty()}. + * @return boolean false if value is null, otherwise {@link String#isEmpty()}. */ private boolean isEmpty(String value) { return value == null ? true : value.trim().isEmpty(); } - /** * Returns true if we are pooling statements. * @@ -1762,13 +1569,11 @@ public class BasicDataSource return this.poolPreparedStatements; } - @Override public boolean isWrapperFor(final Class<?> iface) throws SQLException { return false; } - private void jmxRegister() { // Return immediately if this DataSource has already been registered if (registeredJmxObjectName != null) { @@ -1782,37 +1587,31 @@ public class BasicDataSource try { ObjectNameWrapper.wrap(requestedName).registerMBean(this); } catch (final MalformedObjectNameException e) { - log.warn("The requested JMX name [" + requestedName + - "] was not valid and will be ignored."); + log.warn("The requested JMX name [" + requestedName + "] was not valid and will be ignored."); } } - protected void log(final String message) { if (logWriter != null) { logWriter.println(message); } } - @Override public void postDeregister() { // NO-OP } - @Override public void postRegister(final Boolean registrationDone) { // NO-OP } - @Override public void preDeregister() throws Exception { // NO-OP } - @Override public ObjectName preRegister(final MBeanServer server, final ObjectName objectName) { final String requestedName = getJmxName(); @@ -1820,8 +1619,7 @@ public class BasicDataSource try { registeredJmxObjectName = ObjectNameWrapper.wrap(requestedName); } catch (final MalformedObjectNameException e) { - log.warn("The requested JMX name [" + requestedName + - "] was not valid and will be ignored."); + log.warn("The requested JMX name [" + requestedName + "] was not valid and will be ignored."); } } if (registeredJmxObjectName == null) { @@ -1830,7 +1628,6 @@ public class BasicDataSource return ObjectNameWrapper.unwrap(registeredJmxObjectName); } - /** * Removes a custom connection property. * @@ -1841,10 +1638,8 @@ public class BasicDataSource connectionProperties.remove(name); } - /** - * Sets the print writer to be used by this configuration to log information - * on abandoned objects. + * Sets the print writer to be used by this configuration to log information on abandoned objects. * * @param logWriter The new log writer */ @@ -1859,16 +1654,13 @@ public class BasicDataSource } } - /** - * If the connection pool implements - * {@link org.apache.commons.pool2.UsageTracking UsageTracking}, configure - * whether the connection pool should record a stack trace every time a - * method is called on a pooled connection and retain the most recent stack - * trace to aid debugging of abandoned connections. + * If the connection pool implements {@link org.apache.commons.pool2.UsageTracking UsageTracking}, configure whether + * the connection pool should record a stack trace every time a method is called on a pooled connection and retain + * the most recent stack trace to aid debugging of abandoned connections. * - * @param usageTracking A value of <code>true</code> will enable the - * recording of a stack trace on every use of a pooled connection + * @param usageTracking A value of <code>true</code> will enable the recording of a stack trace on every use of a + * pooled connection */ public void setAbandonedUsageTracking(final boolean usageTracking) { if (abandonedConfig == null) { @@ -1881,17 +1673,14 @@ public class BasicDataSource } } - /** * <p> - * Sets the value of the accessToUnderlyingConnectionAllowed property. It - * controls if the PoolGuard allows access to the underlying connection. - * (Default: false) + * Sets the value of the accessToUnderlyingConnectionAllowed property. It controls if the PoolGuard allows access to + * the underlying connection. (Default: false) * </p> * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * @@ -1901,23 +1690,19 @@ public class BasicDataSource this.accessToUnderlyingConnectionAllowed = allow; } - /** - * Sets the value of the flag that controls whether or not connections being - * returned to the pool will be checked and configured with - * {@link Connection#setAutoCommit(boolean) Connection.setAutoCommit(true)} - * if the auto commit setting is {@code false} when the connection is - * returned. It is <code>true</code> by default. + * Sets the value of the flag that controls whether or not connections being returned to the pool will be checked + * and configured with {@link Connection#setAutoCommit(boolean) Connection.setAutoCommit(true)} if the auto commit + * setting is {@code false} when the connection is returned. It is <code>true</code> by default. * - * @param autoCommitOnReturn Whether or not connections being returned to - * the pool will be checked and configured with auto-commit. + * @param autoCommitOnReturn Whether or not connections being returned to the pool will be checked and configured + * with auto-commit. * @since 2.6.0 */ public void setAutoCommitOnReturn(final boolean autoCommitOnReturn) { this.autoCommitOnReturn = autoCommitOnReturn; } - /** * Sets the state caching flag. * @@ -1927,19 +1712,15 @@ public class BasicDataSource this.cacheState = cacheState; } - /** - * Sets the list of SQL statements to be executed when a physical connection - * is first created. + * Sets the list of SQL statements to be executed when a physical connection is first created. * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * - * @param connectionInitSqls Collection of SQL statements to execute on - * connection creation + * @param connectionInitSqls Collection of SQL statements to execute on connection creation */ public void setConnectionInitSqls(final Collection<String> connectionInitSqls) { if (connectionInitSqls != null && connectionInitSqls.size() > 0) { @@ -1958,7 +1739,6 @@ public class BasicDataSource } } - // ----------------------------------------------------- DataSource Methods /** @@ -1967,12 +1747,10 @@ public class BasicDataSource * Format of the string must be [propertyName=property;]* * </p> * <p> - * NOTE - The "user" and "password" properties will be added explicitly, so - * they do not need to be included here. + * NOTE - The "user" and "password" properties will be added explicitly, so they do not need to be included here. * </p> * - * @param connectionProperties the connection properties used to create new - * connections + * @param connectionProperties the connection properties used to create new connections */ public void setConnectionProperties(final String connectionProperties) { Objects.requireNonNull(connectionProperties, "connectionProperties is null"); @@ -1995,16 +1773,13 @@ public class BasicDataSource this.connectionProperties = properties; } - /** * <p> - * Sets default auto-commit state of connections returned by this - * datasource. + * Sets default auto-commit state of connections returned by this datasource. * </p> * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * @@ -2014,15 +1789,13 @@ public class BasicDataSource this.defaultAutoCommit = defaultAutoCommit; } - /** * <p> * Sets the default catalog. * </p> * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * @@ -2036,11 +1809,9 @@ public class BasicDataSource } } - /** - * Sets the default query timeout that will be used for - * {@link java.sql.Statement Statement}s created from this connection. - * <code>null</code> means that the driver default will be used. + * Sets the default query timeout that will be used for {@link java.sql.Statement Statement}s created from this + * connection. <code>null</code> means that the driver default will be used. * * @param defaultQueryTimeoutSeconds The default query timeout in seconds. */ @@ -2048,15 +1819,13 @@ public class BasicDataSource this.defaultQueryTimeoutSeconds = defaultQueryTimeoutSeconds; } - /** * <p> * Sets defaultReadonly property. * </p> * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * @@ -2066,15 +1835,13 @@ public class BasicDataSource this.defaultReadOnly = defaultReadOnly; } - /** * <p> * Sets the default schema. * </p> * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * @@ -2089,51 +1856,42 @@ public class BasicDataSource } } - /** * <p> * Sets the default transaction isolation state for returned connections. * </p> * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * - * @param defaultTransactionIsolation the default transaction isolation - * state + * @param defaultTransactionIsolation the default transaction isolation state * @see Connection#getTransactionIsolation */ public void setDefaultTransactionIsolation(final int defaultTransactionIsolation) { this.defaultTransactionIsolation = defaultTransactionIsolation; } - /** * Sets the SQL_STATE codes considered to signal fatal conditions. * <p> - * Overrides the defaults in {@link Utils#DISCONNECTION_SQL_CODES} (plus - * anything starting with {@link Utils#DISCONNECTION_SQL_CODE_PREFIX}). If - * this property is non-null and {@link #getFastFailValidation()} is - * {@code true}, whenever connections created by this datasource generate - * exceptions with SQL_STATE codes in this list, they will be marked as - * "fatally disconnected" and subsequent validations will fail fast (no - * attempt at isValid or validation query). + * Overrides the defaults in {@link Utils#DISCONNECTION_SQL_CODES} (plus anything starting with + * {@link Utils#DISCONNECTION_SQL_CODE_PREFIX}). If this property is non-null and {@link #getFastFailValidation()} + * is {@code true}, whenever connections created by this datasource generate exceptions with SQL_STATE codes in this + * list, they will be marked as "fatally disconnected" and subsequent validations will fail fast (no attempt at + * isValid or validation query). * </p> * <p> - * If {@link #getFastFailValidation()} is {@code false} setting this - * property has no effect. + * If {@link #getFastFailValidation()} is {@code false} setting this property has no effect. * </p> * <p> - * 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: {@code getConnection, setLogwriter, + * 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: {@code getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter}. * </p> * - * @param disconnectionSqlCodes SQL_STATE codes considered to signal fatal - * conditions + * @param disconnectionSqlCodes SQL_STATE codes considered to signal fatal conditions * @since 2.1 */ public void setDisconnectionSqlCodes(final Collection<String> disconnectionSqlCodes) { @@ -2153,13 +1911,11 @@ public class BasicDataSource } } - /** * Sets the JDBC Driver instance to use for this pool. * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * @@ -2169,34 +1925,29 @@ public class BasicDataSource this.driver = driver; } - /** * <p> * Sets the class loader to be used to load the JDBC driver. * </p> * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * - * @param driverClassLoader the class loader with which to load the JDBC - * driver + * @param driverClassLoader the class loader with which to load the JDBC driver */ public synchronized void setDriverClassLoader(final ClassLoader driverClassLoader) { this.driverClassLoader = driverClassLoader; } - /** * <p> * Sets the JDBC driver class name. * </p> * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * @@ -2210,7 +1961,6 @@ public class BasicDataSource } } - /** * Sets the ConnectionFactory class name. * @@ -2226,16 +1976,13 @@ public class BasicDataSource } } - /** - * Sets the value of the flag that controls whether or not connections being - * returned to the pool will be checked and configured with - * {@link Connection#setAutoCommit(boolean) Connection.setAutoCommit(true)} - * if the auto commit setting is {@code false} when the connection is - * returned. It is <code>true</code> by default. + * Sets the value of the flag that controls whether or not connections being returned to the pool will be checked + * and configured with {@link Connection#setAutoCommit(boolean) Connection.setAutoCommit(true)} if the auto commit + * setting is {@code false} when the connection is returned. It is <code>true</code> by default. * - * @param autoCommitOnReturn Whether or not connections being returned to - * the pool will be checked and configured with auto-commit. + * @param autoCommitOnReturn Whether or not connections being returned to the pool will be checked and configured + * with auto-commit. * @deprecated Use {@link #setAutoCommitOnReturn(boolean)}. */ @Deprecated @@ -2243,12 +1990,10 @@ public class BasicDataSource this.autoCommitOnReturn = autoCommitOnReturn; } - /** * Sets the EvictionPolicy implementation to use with this connection pool. * - * @param evictionPolicyClassName The fully qualified class name of the - * EvictionPolicy implementation + * @param evictionPolicyClassName The fully qualified class name of the EvictionPolicy implementation */ public synchronized void setEvictionPolicyClassName(final String evictionPolicyClassName) { if (connectionPool != null) { @@ -2257,43 +2002,36 @@ public class BasicDataSource this.evictionPolicyClassName = evictionPolicyClassName; } - /** * @see #getFastFailValidation() - * @param fastFailValidation true means connections created by this factory - * will fast fail validation + * @param fastFailValidation true means connections created by this factory will fast fail validation * @since 2.1 */ public void setFastFailValidation(final boolean fastFailValidation) { this.fastFailValidation = fastFailValidation; } - /** * <p> * Sets the initial size of the connection pool. * </p> * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * - * @param initialSize the number of connections created when the pool is - * initialized + * @param initialSize the number of connections created when the pool is initialized */ public synchronized void setInitialSize(final int initialSize) { this.initialSize = initialSize; } - /** - * Sets the JMX name that has been requested for this DataSource. If the - * requested name is not valid, an alternative may be chosen. This - * DataSource will attempt to register itself using this name. If another - * component registers this DataSource with JMX and this name is valid this - * name will be used in preference to any specified by the other component. + * Sets the JMX name that has been requested for this DataSource. If the requested name is not valid, an alternative + * may be chosen. This DataSource will attempt to register itself using this name. If another component registers + * this DataSource with JMX and this name is valid this name will be used in preference to any specified by the + * other component. * * @param jmxName The JMX name that has been requested for this DataSource */ @@ -2301,10 +2039,8 @@ public class BasicDataSource this.jmxName = jmxName; } - /** - * Sets the LIFO property. True means the pool behaves as a LIFO queue; - * false means FIFO. + * Sets the LIFO property. True means the pool behaves as a LIFO queue; false means FIFO. * * @param lifo the new value for the LIFO property */ @@ -2315,7 +2051,6 @@ public class BasicDataSource } } - /** * @param logAbandoned new logAbandoned property value */ @@ -2330,23 +2065,18 @@ public class BasicDataSource } } - /** - * When {@link #getMaxConnLifetimeMillis()} is set to limit connection - * lifetime, this property determines whether or not log messages are - * generated when the pool closes connections due to maximum lifetime - * exceeded. Set this property to false to suppress log messages when - * connections expire. + * When {@link #getMaxConnLifetimeMillis()} is set to limit connection lifetime, this property determines whether or + * not log messages are generated when the pool closes connections due to maximum lifetime exceeded. Set this + * property to false to suppress log messages when connections expire. * - * @param logExpiredConnections Whether or not log messages are generated - * when the pool closes connections due to maximum lifetime - * exceeded. + * @param logExpiredConnections Whether or not log messages are generated when the pool closes connections due to + * maximum lifetime exceeded. */ public void setLogExpiredConnections(final boolean logExpiredConnections) { this.logExpiredConnections = logExpiredConnections; } - /** * <strong>BasicDataSource does NOT support this method. </strong> * @@ -2354,14 +2084,13 @@ public class BasicDataSource * Set the login timeout (in seconds) for connecting to the database. * </p> * <p> - * Calls {@link #createDataSource()}, so has the side effect of initializing - * the connection pool. + * Calls {@link #createDataSource()}, so has the side effect of initializing the connection pool. * </p> * * @param loginTimeout The new login timeout, or zero for no timeout - * @throws UnsupportedOperationException If the DataSource implementation - * does not support the login timeout feature. - * @throws SQLException if a database access error occurs + * @throws UnsupportedOperationException If the DataSource implementation does not support the login timeout + * feature. + * @throws SQLException if a database access error occurs */ @Override public void setLoginTimeout(final int loginTimeout) throws SQLException { @@ -2370,14 +2099,12 @@ public class BasicDataSource throw new UnsupportedOperationException("Not supported by BasicDataSource"); } - /** * <p> * Sets the log writer being used by this data source. * </p> * <p> - * Calls {@link #createDataSource()}, so has the side effect of initializing - * the connection pool. + * Calls {@link #createDataSource()}, so has the side effect of initializing the connection pool. * </p> * * @param logWriter The new log writer @@ -2389,30 +2116,26 @@ public class BasicDataSource this.logWriter = logWriter; } - /** * <p> - * Sets the maximum permitted lifetime of a connection in milliseconds. A - * value of zero or less indicates an infinite lifetime. + * Sets the maximum permitted lifetime of a connection in milliseconds. A value of zero or less indicates an + * infinite lifetime. * </p> * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * - * @param maxConnLifetimeMillis The maximum permitted lifetime of a - * connection in milliseconds. + * @param maxConnLifetimeMillis The maximum permitted lifetime of a connection in milliseconds. */ public void setMaxConnLifetimeMillis(final long maxConnLifetimeMillis) { this.maxConnLifetimeMillis = maxConnLifetimeMillis; } - /** - * Sets the maximum number of connections that can remain idle in the pool. - * Excess idle connections are destroyed on return to the pool. + * Sets the maximum number of connections that can remain idle in the pool. Excess idle connections are destroyed on + * return to the pool. * * @see #getMaxIdle() * @param maxIdle the new value for maxIdle @@ -2424,15 +2147,13 @@ public class BasicDataSource } } - /** * <p> * Sets the value of the <code>maxOpenPreparedStatements</code> property. * </p> * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * @@ -2442,10 +2163,9 @@ public class BasicDataSource this.maxOpenPreparedStatements = maxOpenStatements; } - /** - * Sets the maximum total number of idle and borrows connections that can be - * active at the same time. Use a negative value for no limit. + * Sets the maximum total number of idle and borrows connections that can be active at the same time. Use a negative + * value for no limit. * * @param maxTotal the new value for maxTotal * @see #getMaxTotal() @@ -2457,10 +2177,8 @@ public class BasicDataSource } } - /** - * Sets the MaxWaitMillis property. Use -1 to make the pool wait - * indefinitely. + * Sets the MaxWaitMillis property. Use -1 to make the pool wait indefinitely. * * @param maxWaitMillis the new value for MaxWaitMillis * @see #getMaxWaitMillis() @@ -2472,12 +2190,10 @@ public class BasicDataSource } } - /** * Sets the {@link #minEvictableIdleTimeMillis} property. * - * @param minEvictableIdleTimeMillis the minimum amount of time an object - * may sit idle in the pool + * @param minEvictableIdleTimeMillis the minimum amount of time an object may sit idle in the pool * @see #minEvictableIdleTimeMillis */ public synchronized void setMinEvictableIdleTimeMillis(final long minEvictableIdleTimeMillis) { @@ -2487,11 +2203,9 @@ public class BasicDataSource } } - /** - * Sets the minimum number of idle connections in the pool. The pool - * attempts to ensure that minIdle connections are available when the idle - * object evictor runs. The value of this property has no effect unless + * Sets the minimum number of idle connections in the pool. The pool attempts to ensure that minIdle connections are + * available when the idle object evictor runs. The value of this property has no effect unless * {@link #timeBetweenEvictionRunsMillis} has a positive value. * * @param minIdle the new value for minIdle @@ -2504,12 +2218,10 @@ public class BasicDataSource } } - /** * Sets the value of the {@link #numTestsPerEvictionRun} property. * - * @param numTestsPerEvictionRun the new {@link #numTestsPerEvictionRun} - * value + * @param numTestsPerEvictionRun the new {@link #numTestsPerEvictionRun} value * @see #numTestsPerEvictionRun */ public synchronized void setNumTestsPerEvictionRun(final int numTestsPerEvictionRun) { @@ -2519,7 +2231,6 @@ public class BasicDataSource } } - // ------------------------------------------------------ Protected Methods /** @@ -2527,9 +2238,8 @@ public class BasicDataSource * Sets the {@link #password}. * </p> * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * @@ -2539,15 +2249,13 @@ public class BasicDataSource this.password = password; } - /** * <p> * Sets whether to pool statements or not. * </p> * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * @@ -2557,10 +2265,9 @@ public class BasicDataSource this.poolPreparedStatements = poolingStatements; } - /** - * @param removeAbandonedOnBorrow true means abandoned connections may be - * removed when connections are borrowed from the pool. + * @param removeAbandonedOnBorrow true means abandoned connections may be removed when connections are borrowed from + * the pool. * @see #getRemoveAbandonedOnBorrow() */ public void setRemoveAbandonedOnBorrow(final boolean removeAbandonedOnBorrow) { @@ -2574,10 +2281,8 @@ public class BasicDataSource } } - /** - * @param removeAbandonedOnMaintenance true means abandoned connections may - * be removed on pool maintenance. + * @param removeAbandonedOnMaintenance true means abandoned connections may be removed on pool maintenance. * @see #getRemoveAbandonedOnMaintenance() */ public void setRemoveAbandonedOnMaintenance(final boolean removeAbandonedOnMaintenance) { @@ -2591,16 +2296,13 @@ public class BasicDataSource } } - /** * <p> - * Sets the timeout in seconds before an abandoned connection can be - * removed. + * Sets the timeout in seconds before an abandoned connection can be removed. * </p> * * <p> - * Setting this property has no effect if - * {@link #getRemoveAbandonedOnBorrow()} and + * Setting this property has no effect if {@link #getRemoveAbandonedOnBorrow()} and * {@link #getRemoveAbandonedOnMaintenance()} are false. * </p> * @@ -2620,43 +2322,35 @@ public class BasicDataSource } } - /** - * Sets the flag that controls if a connection will be rolled back when it - * is returned to the pool if auto commit is not enabled and the connection - * is not read only. + * Sets the flag that controls if a connection will be rolled back when it is returned to the pool if auto commit is + * not enabled and the connection is not read only. * - * @param rollbackOnReturn whether a connection will be rolled back when it - * is returned to the pool. + * @param rollbackOnReturn whether a connection will be rolled back when it is returned to the pool. */ public void setRollbackOnReturn(final boolean rollbackOnReturn) { this.rollbackOnReturn = rollbackOnReturn; } - /** - * Sets the minimum amount of time a connection may sit idle in the pool - * before it is eligible for eviction by the idle object evictor, with the - * extra condition that at least "minIdle" connections remain in the pool. + * Sets the minimum amount of time a connection may sit idle in the pool before it is eligible for eviction by the + * idle object evictor, with the extra condition that at least "minIdle" connections remain in the pool. * - * @param softMinEvictableIdleTimeMillis minimum amount of time a connection - * may sit idle in the pool before it is eligible for eviction, - * assuming there are minIdle idle connections in the pool. + * @param softMinEvictableIdleTimeMillis minimum amount of time a connection may sit idle in the pool before it is + * eligible for eviction, assuming there are minIdle idle connections in the + * pool. * @see #getSoftMinEvictableIdleTimeMillis */ - public synchronized void setSoftMinEvictableIdleTimeMillis( - final long softMinEvictableIdleTimeMillis) { + public synchronized void setSoftMinEvictableIdleTimeMillis(final long softMinEvictableIdleTimeMillis) { this.softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis; if (connectionPool != null) { connectionPool.setSoftMinEvictableIdleTimeMillis(softMinEvictableIdleTimeMillis); } } - /** - * Sets the {@link #testOnBorrow} property. This property determines whether - * or not the pool will validate objects before they are borrowed from the - * pool. + * Sets the {@link #testOnBorrow} property. This property determines whether or not the pool will validate objects + * before they are borrowed from the pool. * * @param testOnBorrow new value for testOnBorrow property */ @@ -2667,11 +2361,9 @@ public class BasicDataSource } } - /** - * Sets the {@link #testOnCreate} property. This property determines whether - * or not the pool will validate objects immediately after they are created - * by the pool + * Sets the {@link #testOnCreate} property. This property determines whether or not the pool will validate objects + * immediately after they are created by the pool * * @param testOnCreate new value for testOnCreate property */ @@ -2682,11 +2374,9 @@ public class BasicDataSource } } - /** - * Sets the <code>testOnReturn</code> property. This property determines - * whether or not the pool will validate objects before they are returned to - * the pool. + * Sets the <code>testOnReturn</code> property. This property determines whether or not the pool will validate + * objects before they are returned to the pool. * * @param testOnReturn new value for testOnReturn property */ @@ -2697,10 +2387,9 @@ public class BasicDataSource } } - /** - * Sets the <code>testWhileIdle</code> property. This property determines - * whether or not the idle object evictor will validate connections. + * Sets the <code>testWhileIdle</code> property. This property determines whether or not the idle object evictor + * will validate connections. * * @param testWhileIdle new value for testWhileIdle property */ @@ -2711,30 +2400,26 @@ public class BasicDataSource } } - /** * Sets the {@link #timeBetweenEvictionRunsMillis} property. * * @param timeBetweenEvictionRunsMillis the new time between evictor runs * @see #timeBetweenEvictionRunsMillis */ - public synchronized void setTimeBetweenEvictionRunsMillis( - final long timeBetweenEvictionRunsMillis) { + public synchronized void setTimeBetweenEvictionRunsMillis(final long timeBetweenEvictionRunsMillis) { this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis; if (connectionPool != null) { connectionPool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); } } - /** * <p> * Sets the {@link #url}. * </p> * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * @@ -2744,15 +2429,13 @@ public class BasicDataSource this.url = url; } - /** * <p> * Sets the {@link #userName}. * </p> * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * @@ -2762,15 +2445,13 @@ public class BasicDataSource this.userName = userName; } - /** * <p> * Sets the {@link #validationQuery}. * </p> * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * @@ -2784,27 +2465,21 @@ public class BasicDataSource } } - /** - * 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. Use a value less than or equal to 0 for no - * 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. Use a value less than or equal to 0 for no timeout. * <p> - * 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: <code>getConnection, setLogwriter, + * 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: <code>getConnection, setLogwriter, * setLoginTimeout, getLoginTimeout, getLogWriter.</code> * </p> * - * @param validationQueryTimeoutSeconds new validation query timeout value - * in seconds + * @param validationQueryTimeoutSeconds new validation query timeout value in seconds */ public void setValidationQueryTimeout(final int validationQueryTimeoutSeconds) { this.validationQueryTimeoutSeconds = validationQueryTimeoutSeconds; } - /** * Starts the connection pool maintenance task, if configured. */ @@ -2814,13 +2489,11 @@ public class BasicDataSource } } - @Override public <T> T unwrap(final Class<T> iface) throws SQLException { throw new SQLException("BasicDataSource is not a wrapper."); } - private void updateJmxName(final GenericObjectPoolConfig<?> config) { if (registeredJmxObjectName == null) { return; @@ -2831,7 +2504,6 @@ public class BasicDataSource config.setJmxNamePrefix(Constants.JMX_CONNECTION_POOL_PREFIX); } - private ConnectionFactory createConnectionFactory(final Driver driver) throws SQLException { if (connectionFactoryClassName != null) { try { @@ -2840,8 +2512,8 @@ public class BasicDataSource .getConstructor(Driver.class, String.class, Properties.class) .newInstance(driver, url, connectionProperties); } catch (final Exception t) { - final String message = "Cannot load ConnectionFactory implementation '" + - connectionFactoryClassName + "'"; + final String message = "Cannot load ConnectionFactory implementation '" + connectionFactoryClassName + + "'"; logWriter.println(message); t.printStackTrace(logWriter); throw new SQLException(message, t);