commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1143885 - in /commons/proper/dbcp/trunk: doc/ src/java/org/apache/commons/dbcp2/ src/java/org/apache/commons/dbcp2/managed/ src/test/org/apache/commons/dbcp2/ src/test/org/apache/commons/dbcp2/managed/
Date Thu, 07 Jul 2011 15:31:55 GMT
Author: markt
Date: Thu Jul  7 15:31:54 2011
New Revision: 1143885

URL: http://svn.apache.org/viewvc?rev=1143885&view=rev
Log:
Preparation for some more pool 2 changes.
Simplify some of the classes with far too many constructors

Modified:
    commons/proper/dbcp/trunk/doc/PoolingDataSourceExample.java
    commons/proper/dbcp/trunk/doc/PoolingDriverExample.java
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDriverManagerConnectionFactory.java
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPStmtPooling.java
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolableConnection.java
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDataSource.java
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDriver.java
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSource.java

Modified: commons/proper/dbcp/trunk/doc/PoolingDataSourceExample.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/doc/PoolingDataSourceExample.java?rev=1143885&r1=1143884&r2=1143885&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/doc/PoolingDataSourceExample.java (original)
+++ commons/proper/dbcp/trunk/doc/PoolingDataSourceExample.java Thu Jul  7 15:31:54 2011
@@ -137,14 +137,16 @@ public class PoolingDataSourceExample {
         // using the connect string passed in the command line
         // arguments.
         //
-        ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectURI,null);
+        ConnectionFactory connectionFactory =
+            new DriverManagerConnectionFactory(connectURI,null);
 
         //
         // Next we'll create the PoolableConnectionFactory, which wraps
         // the "real" Connections created by the ConnectionFactory with
         // the classes that implement the pooling functionality.
         //
-        PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,null,null,false,true);
+        PoolableConnectionFactory poolableConnectionFactory =
+            new PoolableConnectionFactory(connectionFactory);
 
         //
         // Now we'll need a ObjectPool that serves as the
@@ -153,7 +155,8 @@ public class PoolingDataSourceExample {
         // We'll use a GenericObjectPool instance, although
         // any ObjectPool implementation will suffice.
         //
-        ObjectPool connectionPool = new GenericObjectPool(poolableConnectionFactory);
+        ObjectPool connectionPool =
+            new GenericObjectPool(poolableConnectionFactory);
 
         //
         // Finally, we create the PoolingDriver itself,

Modified: commons/proper/dbcp/trunk/doc/PoolingDriverExample.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/doc/PoolingDriverExample.java?rev=1143885&r1=1143884&r2=1143885&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/doc/PoolingDriverExample.java (original)
+++ commons/proper/dbcp/trunk/doc/PoolingDriverExample.java Thu Jul  7 15:31:54 2011
@@ -153,14 +153,16 @@ public class PoolingDriverExample {
         // using the connect string passed in the command line
         // arguments.
         //
-        ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectURI,null);
+        ConnectionFactory connectionFactory =
+            new DriverManagerConnectionFactory(connectURI,null);
 
         //
         // Next, we'll create the PoolableConnectionFactory, which wraps
         // the "real" Connections created by the ConnectionFactory with
         // the classes that implement the pooling functionality.
         //
-        PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,null,null,false,true);
+        PoolableConnectionFactory poolableConnectionFactory =
+            new PoolableConnectionFactory(connectionFactory);
 
         //
         // Now we'll need a ObjectPool that serves as the
@@ -169,7 +171,8 @@ public class PoolingDriverExample {
         // We'll use a GenericObjectPool instance, although
         // any ObjectPool implementation will suffice.
         //
-        ObjectPool connectionPool = new GenericObjectPool(poolableConnectionFactory);
+        ObjectPool connectionPool =
+            new GenericObjectPool(poolableConnectionFactory);
 
         //
         // Finally, we create the PoolingDriver itself...

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java?rev=1143885&r1=1143884&r2=1143885&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java Thu Jul  7 15:31:54 2011
@@ -1774,17 +1774,19 @@ public class BasicDataSource implements 
         PoolableConnectionFactory connectionFactory = null;
         try {
             connectionFactory =
-                new PoolableConnectionFactory(driverConnectionFactory,
-                                              statementPoolFactory,
-                                              validationQuery,
-                                              validationQueryTimeout,
-                                              connectionInitSqls,
-                                              defaultReadOnly,
-                                              defaultAutoCommit,
-                                              defaultTransactionIsolation,
-                                              defaultCatalog,
-                                              cacheState,
-                                              configuration);
+                new PoolableConnectionFactory(driverConnectionFactory);
+            connectionFactory.setStatementPoolFactory(statementPoolFactory);
+            connectionFactory.setValidationQuery(validationQuery);
+            connectionFactory.setValidationQueryTimeout(validationQueryTimeout);
+            connectionFactory.setConnectionInitSql(connectionInitSqls);
+            if (defaultReadOnly != null) {
+                connectionFactory.setDefaultReadOnly(defaultReadOnly.booleanValue());
+            }
+            connectionFactory.setDefaultAutoCommit(defaultAutoCommit);
+            connectionFactory.setDefaultTransactionIsolation(defaultTransactionIsolation);
+            connectionFactory.setDefaultCatalog(defaultCatalog);
+            connectionFactory.setAbandonedConfig(configuration);
+            connectionFactory.setCacheState(cacheState);
             validateConnectionFactory(connectionFactory);
         } catch (RuntimeException e) {
             throw e;

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java?rev=1143885&r1=1143884&r2=1143885&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java (original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java Thu Jul  7 15:31:54 2011
@@ -41,425 +41,11 @@ import org.apache.commons.pool2.ObjectPo
 public class PoolableConnectionFactory implements PoolableObjectFactory {
     /**
      * Create a new <tt>PoolableConnectionFactory</tt>.
-     * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link Connection}s
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.  Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     */
-    public PoolableConnectionFactory(ConnectionFactory connFactory, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit) {
-        _connFactory = connFactory;
-        _stmtPoolFactory = stmtPoolFactory;
-        _validationQuery = validationQuery;
-        _defaultReadOnly = defaultReadOnly ? Boolean.TRUE : Boolean.FALSE;
-        _defaultAutoCommit = defaultAutoCommit;
-    }
-
-    /**
-     * Create a new <tt>PoolableConnectionFactory</tt>.
-     * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link Connection}s
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.  Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param connectionInitSqls a Collection of SQL statements to initialize {@link Connection}s. Using <tt>null</tt> turns off initialization.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     * @since 1.3
-     */
-    public PoolableConnectionFactory(ConnectionFactory connFactory, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, Collection connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit) {
-        _connFactory = connFactory;
-        _stmtPoolFactory = stmtPoolFactory;
-        _validationQuery = validationQuery;
-        _connectionInitSqls = connectionInitSqls;
-        _defaultReadOnly = defaultReadOnly ? Boolean.TRUE : Boolean.FALSE;
-        _defaultAutoCommit = defaultAutoCommit;
-    }
-    
-    /**
-     * Create a new <tt>PoolableConnectionFactory</tt>.
-     * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link Connection}s
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.  Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param validationQueryTimeout the number of seconds that validation queries will wait for database response before failing.  Use a value less than or equal to 0 for no timeout.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     * @since 1.3
-     */
-    public PoolableConnectionFactory(ConnectionFactory connFactory, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, int validationQueryTimeout, boolean defaultReadOnly, boolean defaultAutoCommit) {
-        _connFactory = connFactory;
-        _stmtPoolFactory = stmtPoolFactory;
-        _validationQuery = validationQuery;
-        _validationQueryTimeout = validationQueryTimeout;
-        _defaultReadOnly = defaultReadOnly ? Boolean.TRUE : Boolean.FALSE;
-        _defaultAutoCommit = defaultAutoCommit;
-    }
-    
-    /**
-     * Create a new <tt>PoolableConnectionFactory</tt>.
-     * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link Connection}s
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.  Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param validationQueryTimeout the number of seconds that validation queries will wait for database response before failing.  Use a value less than or equal to 0 for no timeout.
-     * @param connectionInitSqls a Collection of SQL statements to initialize {@link Connection}s. Using <tt>null</tt> turns off initialization.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     * @since 1.3
-     */
-    public PoolableConnectionFactory(ConnectionFactory connFactory, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, int validationQueryTimeout, Collection connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit) {
-        _connFactory = connFactory;
-        _stmtPoolFactory = stmtPoolFactory;
-        _validationQuery = validationQuery;
-        _validationQueryTimeout = validationQueryTimeout;
-        _connectionInitSqls = connectionInitSqls;
-        _defaultReadOnly = defaultReadOnly ? Boolean.TRUE : Boolean.FALSE;
-        _defaultAutoCommit = defaultAutoCommit;
-    }
-
-    /**
-     * Create a new <tt>PoolableConnectionFactory</tt>.
-     * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link Connection}s
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.  Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     * @param defaultTransactionIsolation the default "Transaction Isolation" setting for returned {@link Connection}s
-     */
-    public PoolableConnectionFactory(ConnectionFactory connFactory, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation) {
-        _connFactory = connFactory;
-        _stmtPoolFactory = stmtPoolFactory;
-        _validationQuery = validationQuery;
-        _defaultReadOnly = defaultReadOnly ? Boolean.TRUE : Boolean.FALSE;
-        _defaultAutoCommit = defaultAutoCommit;
-        _defaultTransactionIsolation = defaultTransactionIsolation;
-    }
-
-    /**
-     * Create a new <tt>PoolableConnectionFactory</tt>.
-     * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link Connection}s
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.  Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param connectionInitSqls a Collection of SQL statement to initialize {@link Connection}s. Using <tt>null</tt> turns off initialization.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     * @param defaultTransactionIsolation the default "Transaction Isolation" setting for returned {@link Connection}s
-     * @since 1.3
-     */
-    public PoolableConnectionFactory(ConnectionFactory connFactory, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, Collection connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation) {
-        _connFactory = connFactory;
-        _stmtPoolFactory = stmtPoolFactory;
-        _validationQuery = validationQuery;
-        _connectionInitSqls = connectionInitSqls;
-        _defaultReadOnly = defaultReadOnly ? Boolean.TRUE : Boolean.FALSE;
-        _defaultAutoCommit = defaultAutoCommit;
-        _defaultTransactionIsolation = defaultTransactionIsolation;
-    }
-    
-    /**
-     * Create a new <tt>PoolableConnectionFactory</tt>.
-     * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link Connection}s
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.  Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param validationQueryTimeout the number of seconds that validation queries will wait for database response before failing.  Use a value less than or equal to 0 for no timeout.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     * @param defaultTransactionIsolation the default "Transaction Isolation" setting for returned {@link Connection}s
-     * @since 1.3
-     */
-    public PoolableConnectionFactory(ConnectionFactory connFactory, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, int validationQueryTimeout, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation) {
-        _connFactory = connFactory;
-        _stmtPoolFactory = stmtPoolFactory;
-        _validationQuery = validationQuery;
-        _validationQueryTimeout = validationQueryTimeout;
-        _defaultReadOnly = defaultReadOnly ? Boolean.TRUE : Boolean.FALSE;
-        _defaultAutoCommit = defaultAutoCommit;
-        _defaultTransactionIsolation = defaultTransactionIsolation;
-    }
-    
-    /**
-     * Create a new <tt>PoolableConnectionFactory</tt>.
-     * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link Connection}s
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.  Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param validationQueryTimeout the number of seconds that validation queries will wait for database response before failing.  Use a value less than or equal to 0 for no timeout.
-     * @param connectionInitSqls a Collection of SQL statement to initialize {@link Connection}s. Using <tt>null</tt> turns off initialization.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     * @param defaultTransactionIsolation the default "Transaction Isolation" setting for returned {@link Connection}s
-     * @since 1.3
-     */
-    public PoolableConnectionFactory(ConnectionFactory connFactory, KeyedObjectPoolFactory stmtPoolFactory, String validationQuery, int validationQueryTimeout, Collection connectionInitSqls, boolean defaultReadOnly, boolean defaultAutoCommit, int defaultTransactionIsolation) {
-        _connFactory = connFactory;
-        _stmtPoolFactory = stmtPoolFactory;
-        _validationQuery = validationQuery;
-        _validationQueryTimeout = validationQueryTimeout;
-        _connectionInitSqls = connectionInitSqls;
-        _defaultReadOnly = defaultReadOnly ? Boolean.TRUE : Boolean.FALSE;
-        _defaultAutoCommit = defaultAutoCommit;
-        _defaultTransactionIsolation = defaultTransactionIsolation;
-    }
-
-    /**
-     * Create a new <tt>PoolableConnectionFactory</tt>.
-     * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link Connection}s
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.  Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     * @param config the AbandonedConfig if tracing SQL objects
-     */
-    public PoolableConnectionFactory(
-        ConnectionFactory connFactory,
-        KeyedObjectPoolFactory stmtPoolFactory,
-        String validationQuery,
-        boolean defaultReadOnly,
-        boolean defaultAutoCommit,
-        AbandonedConfig config) {
-
-        _connFactory = connFactory;
-        _config = config;
-        _stmtPoolFactory = stmtPoolFactory;
-        _validationQuery = validationQuery;
-        _defaultReadOnly = defaultReadOnly ? Boolean.TRUE : Boolean.FALSE;
-        _defaultAutoCommit = defaultAutoCommit;
-    }
-
-    /**
-     * Create a new <tt>PoolableConnectionFactory</tt>.
-     * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link Connection}s
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.  Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     * @param defaultTransactionIsolation the default "Transaction Isolation" setting for returned {@link Connection}s
-     * @param config the AbandonedConfig if tracing SQL objects
-     */
-    public PoolableConnectionFactory(
-        ConnectionFactory connFactory,
-        KeyedObjectPoolFactory stmtPoolFactory,
-        String validationQuery,
-        boolean defaultReadOnly,
-        boolean defaultAutoCommit,
-        int defaultTransactionIsolation,
-        AbandonedConfig config) {
-
-        _connFactory = connFactory;
-        _config = config;
-        _stmtPoolFactory = stmtPoolFactory;
-        _validationQuery = validationQuery;
-        _defaultReadOnly = defaultReadOnly ? Boolean.TRUE : Boolean.FALSE;
-        _defaultAutoCommit = defaultAutoCommit;
-        _defaultTransactionIsolation = defaultTransactionIsolation;
-    }
-
-    /**
-     * Create a new <tt>PoolableConnectionFactory</tt>.
-     * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link Connection}s
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.  Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     * @param defaultTransactionIsolation the default "Transaction Isolation" setting for returned {@link Connection}s
-     * @param defaultCatalog the default "catalog" setting for returned {@link Connection}s
-     * @param config the AbandonedConfig if tracing SQL objects
-     */
-    public PoolableConnectionFactory(
-        ConnectionFactory connFactory,
-        KeyedObjectPoolFactory stmtPoolFactory,
-        String validationQuery,
-        boolean defaultReadOnly,
-        boolean defaultAutoCommit,
-        int defaultTransactionIsolation,
-        String defaultCatalog,
-        AbandonedConfig config) {
-
-        _connFactory = connFactory;
-        _config = config;
-        _stmtPoolFactory = stmtPoolFactory;
-        _validationQuery = validationQuery;
-        _defaultReadOnly = defaultReadOnly ? Boolean.TRUE : Boolean.FALSE;
-        _defaultAutoCommit = defaultAutoCommit;
-        _defaultTransactionIsolation = defaultTransactionIsolation;
-        _defaultCatalog = defaultCatalog;
-    }
-
-    /**
-     * Create a new <tt>PoolableConnectionFactory</tt>.
-     * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link Connection}s
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.  Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     * @param defaultTransactionIsolation the default "Transaction Isolation" setting for returned {@link Connection}s
-     * @param defaultCatalog the default "catalog" setting for returned {@link Connection}s
-     * @param config the AbandonedConfig if tracing SQL objects
-     */
-    public PoolableConnectionFactory(
-        ConnectionFactory connFactory,
-        KeyedObjectPoolFactory stmtPoolFactory,
-        String validationQuery,
-        Boolean defaultReadOnly,
-        boolean defaultAutoCommit,
-        int defaultTransactionIsolation,
-        String defaultCatalog,
-        AbandonedConfig config) {
-
-        _connFactory = connFactory;
-        _config = config;
-        _stmtPoolFactory = stmtPoolFactory;
-        _validationQuery = validationQuery;
-        _defaultReadOnly = defaultReadOnly;
-        _defaultAutoCommit = defaultAutoCommit;
-        _defaultTransactionIsolation = defaultTransactionIsolation;
-        _defaultCatalog = defaultCatalog;
-    }
-
-    /**
-     * Create a new <tt>PoolableConnectionFactory</tt>.
-     * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link Connection}s
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.  Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param connectionInitSqls a Collection of SQL statements to initialize {@link Connection}s. Using <tt>null</tt> turns off initialization.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     * @param defaultTransactionIsolation the default "Transaction Isolation" setting for returned {@link Connection}s
-     * @param defaultCatalog the default "catalog" setting for returned {@link Connection}s
-     * @param config the AbandonedConfig if tracing SQL objects
-     * @since 1.3
+     * @param connFactory the {@link ConnectionFactory} from which to obtain
+     * base {@link Connection}s
      */
-    public PoolableConnectionFactory(
-        ConnectionFactory connFactory,
-        KeyedObjectPoolFactory stmtPoolFactory,
-        String validationQuery,
-        Collection connectionInitSqls,
-        Boolean defaultReadOnly,
-        boolean defaultAutoCommit,
-        int defaultTransactionIsolation,
-        String defaultCatalog,
-        AbandonedConfig config) {
-
+    public PoolableConnectionFactory(ConnectionFactory connFactory) {
         _connFactory = connFactory;
-        _config = config;
-        _stmtPoolFactory = stmtPoolFactory;
-        _validationQuery = validationQuery;
-        _connectionInitSqls = connectionInitSqls;
-        _defaultReadOnly = defaultReadOnly;
-        _defaultAutoCommit = defaultAutoCommit;
-        _defaultTransactionIsolation = defaultTransactionIsolation;
-        _defaultCatalog = defaultCatalog;
-    }
-    
-    /**
-     * Create a new <tt>PoolableConnectionFactory</tt>.
-     * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link Connection}s
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.  Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param validationQueryTimeout the number of seconds that validation queries will wait for database response before failing.  Use a value less than or equal to 0 for no timeout.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     * @param defaultTransactionIsolation the default "Transaction Isolation" setting for returned {@link Connection}s
-     * @param defaultCatalog the default "catalog" setting for returned {@link Connection}s
-     * @param config the AbandonedConfig if tracing SQL objects
-     * @since 1.3
-     */
-    public PoolableConnectionFactory(
-        ConnectionFactory connFactory,
-        KeyedObjectPoolFactory stmtPoolFactory,
-        String validationQuery,
-        int validationQueryTimeout,
-        Boolean defaultReadOnly,
-        boolean defaultAutoCommit,
-        int defaultTransactionIsolation,
-        String defaultCatalog,
-        AbandonedConfig config) {
-
-        _connFactory = connFactory;
-        _config = config;
-        _stmtPoolFactory = stmtPoolFactory;
-        _validationQuery = validationQuery;
-        _validationQueryTimeout = validationQueryTimeout;
-        _defaultReadOnly = defaultReadOnly;
-        _defaultAutoCommit = defaultAutoCommit;
-        _defaultTransactionIsolation = defaultTransactionIsolation;
-        _defaultCatalog = defaultCatalog;
-    }
-    
-    /**
-     * Create a new <tt>PoolableConnectionFactory</tt>.
-     * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link Connection}s
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.  Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param validationQueryTimeout the number of seconds that validation queries will wait for database response before failing.  Use a value less than or equal to 0 for no timeout.
-     * @param connectionInitSqls a Collection of SQL statements to initialize {@link Connection}s. Using <tt>null</tt> turns off initialization.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     * @param defaultTransactionIsolation the default "Transaction Isolation" setting for returned {@link Connection}s
-     * @param defaultCatalog the default "catalog" setting for returned {@link Connection}s
-     * @param config the AbandonedConfig if tracing SQL objects
-     * @param cacheState the state caching flag for returned {@link Connection}s
-     * @since 1.3
-     */
-    public PoolableConnectionFactory(
-        ConnectionFactory connFactory,
-        KeyedObjectPoolFactory stmtPoolFactory,
-        String validationQuery,
-        int validationQueryTimeout,
-        Collection connectionInitSqls,
-        Boolean defaultReadOnly,
-        boolean defaultAutoCommit,
-        int defaultTransactionIsolation,
-        String defaultCatalog,
-        AbandonedConfig config) {
-
-        _connFactory = connFactory;
-        _config = config;
-        _stmtPoolFactory = stmtPoolFactory;
-        _validationQuery = validationQuery;
-        _validationQueryTimeout = validationQueryTimeout;
-        _connectionInitSqls = connectionInitSqls;
-        _defaultReadOnly = defaultReadOnly;
-        _defaultAutoCommit = defaultAutoCommit;
-        _defaultTransactionIsolation = defaultTransactionIsolation;
-        _defaultCatalog = defaultCatalog;
-    }
-
-    /**
-     * Create a new <tt>PoolableConnectionFactory</tt>.
-     * @param connFactory the {@link ConnectionFactory} from which to obtain base {@link Connection}s
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.  Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param validationQueryTimeout the number of seconds that validation queries will wait for database response before failing.  Use a value less than or equal to 0 for no timeout.
-     * @param connectionInitSqls a Collection of SQL statements to initialize {@link Connection}s. Using <tt>null</tt> turns off initialization.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     * @param defaultTransactionIsolation the default "Transaction Isolation" setting for returned {@link Connection}s
-     * @param defaultCatalog the default "catalog" setting for returned {@link Connection}s
-     * @param config the AbandonedConfig if tracing SQL objects
-     * @param cacheState the state caching flag for returned {@link Connection}s
-     * @since 2.0
-     */
-    public PoolableConnectionFactory(
-        ConnectionFactory connFactory,
-        KeyedObjectPoolFactory stmtPoolFactory,
-        String validationQuery,
-        int validationQueryTimeout,
-        Collection connectionInitSqls,
-        Boolean defaultReadOnly,
-        boolean defaultAutoCommit,
-        int defaultTransactionIsolation,
-        String defaultCatalog,
-        boolean cacheState,
-        AbandonedConfig config) {
-
-        _connFactory = connFactory;
-        _config = config;
-        _stmtPoolFactory = stmtPoolFactory;
-        _validationQuery = validationQuery;
-        _validationQueryTimeout = validationQueryTimeout;
-        _connectionInitSqls = connectionInitSqls;
-        _defaultReadOnly = defaultReadOnly;
-        _defaultAutoCommit = defaultAutoCommit;
-        _defaultTransactionIsolation = defaultTransactionIsolation;
-        _defaultCatalog = defaultCatalog;
-        _cacheState = cacheState;
     }
 
     /**
@@ -568,6 +154,14 @@ public class PoolableConnectionFactory i
         _defaultCatalog = defaultCatalog;
     }
 
+    public void setAbandonedConfig(AbandonedConfig abandonedConfig) {
+        this._config = abandonedConfig;
+    }
+
+    public void setCacheState(boolean cacheState) {
+        this._cacheState = cacheState;
+    }
+
     @Override
     public Object makeObject() throws Exception {
         Connection conn = _connFactory.createConnection();

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java?rev=1143885&r1=1143884&r2=1143885&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java Thu Jul  7 15:31:54 2011
@@ -186,17 +186,19 @@ public class BasicManagedDataSource exte
             AbandonedConfig abandonedConfig) throws SQLException {
         PoolableConnectionFactory connectionFactory = null;
         try {
-            connectionFactory =
-                new PoolableManagedConnectionFactory((XAConnectionFactory) driverConnectionFactory,
-                                              statementPoolFactory,
-                                              validationQuery,
-                                              validationQueryTimeout,
-                                              connectionInitSqls,
-                                              defaultReadOnly,
-                                              defaultAutoCommit,
-                                              defaultTransactionIsolation,
-                                              defaultCatalog,
-                                              abandonedConfig);
+            connectionFactory = new PoolableManagedConnectionFactory(
+                    (XAConnectionFactory) driverConnectionFactory);
+            connectionFactory.setStatementPoolFactory(statementPoolFactory);
+            connectionFactory.setValidationQuery(validationQuery);
+            connectionFactory.setValidationQueryTimeout(validationQueryTimeout);
+            connectionFactory.setConnectionInitSql(connectionInitSqls);
+            if (defaultReadOnly != null) {
+                connectionFactory.setDefaultReadOnly(defaultReadOnly.booleanValue());
+            }
+            connectionFactory.setDefaultAutoCommit(defaultAutoCommit);
+            connectionFactory.setDefaultTransactionIsolation(defaultTransactionIsolation);
+            connectionFactory.setDefaultCatalog(defaultCatalog);
+            connectionFactory.setAbandonedConfig(abandonedConfig);
             validateConnectionFactory(connectionFactory);
         } catch (RuntimeException e) {
             throw e;

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java?rev=1143885&r1=1143884&r2=1143885&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java (original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java Thu Jul  7 15:31:54 2011
@@ -17,14 +17,10 @@
 
 package org.apache.commons.dbcp2.managed;
 import java.sql.Connection;
-import java.util.Collection;
 
-import org.apache.commons.dbcp2.AbandonedConfig;
 import org.apache.commons.dbcp2.PoolableConnectionFactory;
 import org.apache.commons.dbcp2.PoolingConnection;
 import org.apache.commons.pool2.KeyedObjectPool;
-import org.apache.commons.pool2.KeyedObjectPoolFactory;
-import org.apache.commons.pool2.ObjectPool;
 
 /**
  * A {@link PoolableConnectionFactory} that creates {@link PoolableManagedConnection}s.
@@ -40,56 +36,13 @@ public class PoolableManagedConnectionFa
      * Create a PoolableManagedConnectionFactory and attach it to a connection pool.
      * 
      * @param connFactory XAConnectionFactory
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling
-     * {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.
-     * Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
      */
-    public PoolableManagedConnectionFactory(XAConnectionFactory connFactory,
-            KeyedObjectPoolFactory stmtPoolFactory,
-            String validationQuery, boolean defaultReadOnly,
-            boolean defaultAutoCommit) {
-        super(connFactory, stmtPoolFactory, validationQuery,
-                defaultReadOnly, defaultAutoCommit);
+    public PoolableManagedConnectionFactory(XAConnectionFactory connFactory) {
+        super(connFactory);
         this.transactionRegistry = connFactory.getTransactionRegistry();
     }
     
     /**
-     * Create a PoolableManagedConnectionFactory and attach it to a connection pool.
-     * 
-     * @param connFactory XAConnectionFactory
-     * @param stmtPoolFactory the {@link KeyedObjectPoolFactory} to use to create {@link KeyedObjectPool}s for pooling
-     * {@link java.sql.PreparedStatement}s, or <tt>null</tt> to disable {@link java.sql.PreparedStatement} pooling
-     * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.
-     * Should return at least one row. Using <tt>null</tt> turns off validation.
-     * @param validationQueryTimeout the number of seconds that validation queries will wait for database response
-     * before failing. Use a value less than or equal to 0 for no timeout.
-     * @param connectionInitSqls a Collection of SQL statements to initialize {@link Connection}s.
-     * Using <tt>null</tt> turns off initialization.
-     * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
-     * @param defaultAutoCommit the default "auto commit" setting for returned {@link Connection}s
-     * @param defaultTransactionIsolation the default "Transaction Isolation" setting for returned {@link Connection}s
-     * @param defaultCatalog the default "catalog" setting for returned {@link Connection}s
-     * @param config the AbandonedConfig if tracing SQL objects
-     */
-    public PoolableManagedConnectionFactory(XAConnectionFactory connFactory,
-            KeyedObjectPoolFactory stmtPoolFactory,
-            String validationQuery,
-            int validationQueryTimeout,
-            Collection connectionInitSqls,
-            Boolean defaultReadOnly,
-            boolean defaultAutoCommit,
-            int defaultTransactionIsolation,
-            String defaultCatalog,
-            AbandonedConfig config) {
-        super(connFactory, stmtPoolFactory, validationQuery, validationQueryTimeout, connectionInitSqls,
-                defaultReadOnly, defaultAutoCommit, defaultTransactionIsolation, defaultCatalog, config);
-        this.transactionRegistry = connFactory.getTransactionRegistry();
-    }
-
-    /**
      * Uses the configured XAConnectionFactory to create a {@link PoolableManagedConnection}.
      * Throws <code>IllegalStateException</code> if the connection factory returns null.
      * Also initializes the connection using configured initialization sql (if provided)

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDriverManagerConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDriverManagerConnectionFactory.java?rev=1143885&r1=1143884&r2=1143885&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDriverManagerConnectionFactory.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestDriverManagerConnectionFactory.java Thu Jul  7 15:31:54 2011
@@ -23,7 +23,6 @@ import javax.sql.DataSource;
 
 import org.apache.commons.pool2.impl.GenericObjectPool;
 import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
-import org.apache.commons.pool2.impl.WhenExhaustedAction;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -57,8 +56,10 @@ public class TestDriverManagerConnection
                     "jdbc:apache:commons:testdriver",
                     "foo", "bar");
         final PoolableConnectionFactory poolableConnectionFactory =
-            new PoolableConnectionFactory(connectionFactory,
-                    null, null, false, true);
+            new PoolableConnectionFactory(connectionFactory);
+        poolableConnectionFactory.setDefaultReadOnly(false);
+        poolableConnectionFactory.setDefaultAutoCommit(true);
+
         GenericObjectPool connectionPool =
             new GenericObjectPool(poolableConnectionFactory, config);
         poolableConnectionFactory.setPool(connectionPool);

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPStmtPooling.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPStmtPooling.java?rev=1143885&r1=1143884&r2=1143885&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPStmtPooling.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPStmtPooling.java Thu Jul  7 15:31:54 2011
@@ -57,8 +57,11 @@ public class TestPStmtPooling extends Te
             new GenericKeyedObjectPoolFactory(
                     new GenericKeyedObjectPoolConfig());
 
-        PoolableConnectionFactory pcf = new PoolableConnectionFactory(
-                connFactory, stmtPoolFactory, null, false, true);
+        PoolableConnectionFactory pcf =
+            new PoolableConnectionFactory(connFactory);
+        pcf.setStatementPoolFactory(stmtPoolFactory);
+        pcf.setDefaultReadOnly(false);
+        pcf.setDefaultAutoCommit(true);
         ObjectPool connPool = new GenericObjectPool(pcf);
 
         DataSource ds = new PoolingDataSource(connPool);
@@ -82,8 +85,11 @@ public class TestPStmtPooling extends Te
             new GenericKeyedObjectPoolFactory(
                     new GenericKeyedObjectPoolConfig());
 
-        PoolableConnectionFactory pcf = new PoolableConnectionFactory(
-                connFactory, stmtPoolFactory, null, false, true);
+        PoolableConnectionFactory pcf =
+            new PoolableConnectionFactory(connFactory);
+        pcf.setStatementPoolFactory(stmtPoolFactory);
+        pcf.setDefaultReadOnly(false);
+        pcf.setDefaultAutoCommit(true);
 
         ObjectPool connPool = new GenericObjectPool(pcf);
 
@@ -121,8 +127,11 @@ public class TestPStmtPooling extends Te
             new GenericKeyedObjectPoolFactory(
                     new GenericKeyedObjectPoolConfig());
 
-        PoolableConnectionFactory pcf = new PoolableConnectionFactory(
-                connFactory, stmtPoolFactory, null, false, true);
+        PoolableConnectionFactory pcf =
+            new PoolableConnectionFactory(connFactory);
+        pcf.setStatementPoolFactory(stmtPoolFactory);
+        pcf.setDefaultReadOnly(false);
+        pcf.setDefaultAutoCommit(true);
 
         ObjectPool connPool = new GenericObjectPool(pcf);
 

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolableConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolableConnection.java?rev=1143885&r1=1143884&r2=1143885&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolableConnection.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolableConnection.java Thu Jul  7 15:31:54 2011
@@ -44,10 +44,12 @@ public class TestPoolableConnection exte
 
     @Override
     public void setUp() throws Exception {
-        PoolableConnectionFactory factory = 
-            new PoolableConnectionFactory(
-                new DriverConnectionFactory(new TesterDriver(),"jdbc:apache:commons:testdriver", null),
-                null, null, true, true);
+        PoolableConnectionFactory factory = new PoolableConnectionFactory(
+                new DriverConnectionFactory(
+                        new TesterDriver(),"jdbc:apache:commons:testdriver", null));
+        factory.setDefaultAutoCommit(true);
+        factory.setDefaultReadOnly(true);
+
         pool = new GenericObjectPool(factory);
         factory.setPool(pool);
     }

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDataSource.java?rev=1143885&r1=1143884&r2=1143885&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDataSource.java Thu Jul  7 15:31:54 2011
@@ -53,11 +53,13 @@ public class TestPoolingDataSource exten
         Properties props = new Properties();
         props.setProperty("user", "username");
         props.setProperty("password", "password");
-         PoolableConnectionFactory factory = 
+        PoolableConnectionFactory factory = 
             new PoolableConnectionFactory(
                 new DriverConnectionFactory(new TesterDriver(),
-                        "jdbc:apache:commons:testdriver", props),
-                null, "SELECT DUMMY FROM DUAL", true, true);
+                        "jdbc:apache:commons:testdriver", props));
+        factory.setValidationQuery("SELECT DUMMY FROM DUAL");
+        factory.setDefaultReadOnly(true);
+        factory.setDefaultAutoCommit(true);
         pool = new GenericObjectPool(factory);
         factory.setPool(pool);
         pool.setMaxTotal(getMaxTotal());
@@ -162,7 +164,9 @@ public class TestPoolingDataSource exten
     private static class NonDelegatingPoolableConnectionFactory
             extends PoolableConnectionFactory {
         public NonDelegatingPoolableConnectionFactory(ConnectionFactory connFactory) {
-            super(connFactory, null, null, true, true);
+            super(connFactory);
+            super.setDefaultAutoCommit(true);
+            super.setDefaultReadOnly(true);
         }
     
         @Override

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDriver.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDriver.java?rev=1143885&r1=1143884&r2=1143885&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDriver.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDriver.java Thu Jul  7 15:31:54 2011
@@ -76,7 +76,11 @@ public class TestPoolingDriver extends T
         GenericKeyedObjectPoolFactory opf =
             new GenericKeyedObjectPoolFactory(keyedPoolConfig);
 
-        PoolableConnectionFactory pcf = new PoolableConnectionFactory(cf, opf, "SELECT COUNT(*) FROM DUAL", false, true);
+        PoolableConnectionFactory pcf = new PoolableConnectionFactory(cf);
+        pcf.setStatementPoolFactory(opf);
+        pcf.setValidationQuery("SELECT COUNT(*) FROM DUAL");
+        pcf.setDefaultReadOnly(false);
+        pcf.setDefaultAutoCommit(true);
 
         GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
         poolConfig.setMaxTotal(getMaxTotal());
@@ -106,14 +110,20 @@ public class TestPoolingDriver extends T
     
     public void test1() {
         ConnectionFactory connectionFactory = new DriverManagerConnectionFactory("jdbc:some:connect:string","username","password");
-        PoolableConnectionFactory pcf = new PoolableConnectionFactory(connectionFactory,null,null,false,true);
+        PoolableConnectionFactory pcf =
+            new PoolableConnectionFactory(connectionFactory);
+        pcf.setDefaultReadOnly(false);
+        pcf.setDefaultAutoCommit(true);
         GenericObjectPool connectionPool = new GenericObjectPool(pcf);
         new PoolingDataSource(connectionPool);
     }
 
     public void test2() {
         ConnectionFactory connectionFactory = new DriverManagerConnectionFactory("jdbc:some:connect:string","username","password");
-        PoolableConnectionFactory pcf = new PoolableConnectionFactory(connectionFactory,null,null,false,true);
+        PoolableConnectionFactory pcf =
+            new PoolableConnectionFactory(connectionFactory);
+        pcf.setDefaultReadOnly(false);
+        pcf.setDefaultAutoCommit(true);
         GenericObjectPool connectionPool = new GenericObjectPool(pcf);
         PoolingDriver driver2 = new PoolingDriver();
         driver2.registerPool("example",connectionPool);
@@ -151,12 +161,9 @@ public class TestPoolingDriver extends T
             "username", 
             "password");
         PoolableConnectionFactory poolableConnectionFactory = 
-            new PoolableConnectionFactory(
-                connectionFactory,
-                null,
-                null,
-                false,
-                true);
+            new PoolableConnectionFactory(connectionFactory);
+        poolableConnectionFactory.setDefaultReadOnly(false);
+        poolableConnectionFactory.setDefaultAutoCommit(true);
         ObjectPool connectionPool =
             new GenericObjectPool(poolableConnectionFactory,config);
         poolableConnectionFactory.setPool(connectionPool);

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSource.java?rev=1143885&r1=1143884&r2=1143885&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSource.java Thu Jul  7 15:31:54 2011
@@ -74,7 +74,11 @@ public class TestManagedDataSource exten
         XAConnectionFactory xaConnectionFactory = new LocalXAConnectionFactory(transactionManager, connectionFactory);
 
         // create the pool object factory
-        PoolableConnectionFactory factory = new PoolableConnectionFactory(xaConnectionFactory, null, "SELECT DUMMY FROM DUAL", true, true);
+        PoolableConnectionFactory factory =
+            new PoolableConnectionFactory(xaConnectionFactory);
+        factory.setValidationQuery("SELECT DUMMY FROM DUAL");
+        factory.setDefaultReadOnly(true);
+        factory.setDefaultAutoCommit(true);
 
         // create the pool
         pool = new GenericObjectPool(factory);
@@ -240,7 +244,9 @@ public class TestManagedDataSource exten
     private static class NonDelegatingPoolableConnectionFactory
             extends PoolableConnectionFactory {
         public NonDelegatingPoolableConnectionFactory(ConnectionFactory connFactory) {
-            super(connFactory, null, null, true, true);
+            super(connFactory);
+            super.setDefaultAutoCommit(true);
+            super.setDefaultReadOnly(true);
         }
 
         @Override



Mime
View raw message