commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1567033 - in /commons/proper/dbcp/trunk/src: changes/ main/java/org/apache/commons/dbcp2/ main/java/org/apache/commons/dbcp2/datasources/ main/java/org/apache/commons/dbcp2/managed/ site/xdoc/ test/java/org/apache/commons/dbcp2/ test/java/...
Date Tue, 11 Feb 2014 10:31:32 GMT
Author: markt
Date: Tue Feb 11 10:31:32 2014
New Revision: 1567033

URL: http://svn.apache.org/r1567033
Log:
Fix DBCP-234
The default values for readOnly, autoCommit and transactionIsolation are now taken from the
JDBC driver. No calls to setReadOnly(), setAutoCommit() or setTransactionIsolation() will
be made for a newly borrowed connection unless a default is explicitly configured (and the
connection is currently using a different setting). 

Modified:
    commons/proper/dbcp/trunk/src/changes/changes.xml
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSourceFactory.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSourceMXBean.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyObjectFactory.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java
    commons/proper/dbcp/trunk/src/site/xdoc/configuration.xml
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java

Modified: commons/proper/dbcp/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/changes/changes.xml?rev=1567033&r1=1567032&r2=1567033&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/changes/changes.xml (original)
+++ commons/proper/dbcp/trunk/src/changes/changes.xml Tue Feb 11 10:31:32 2014
@@ -140,6 +140,13 @@ The <action> type attribute can be add,u
       <action dev="markt" issue="DBCP-410" type="fix" due-to="Andreas Sturmlechner">
         Correct path to Javadoc overview in build.xml.
       </action>
+      <action dev="markt" issue="DBCP-234" type="fix">
+        The default values for readOnly, autoCommit and transactionIsolation are
+        now taken from the JDBC driver. No calls to setReadOnly(),
+        setAutoCommit() or setTransactionIsolation() will be made for a newly
+        borrowed connection unless a default is explicitly configured and the
+        connection is currently using a different setting. 
+      </action>
     </release>
     <release version="1.5.1" date="TBD" description="TBD">
       <action dev="markt" issue="DBCP-400" type="fix">

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java?rev=1567033&r1=1567032&r2=1567033&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
Tue Feb 11 10:31:32 2014
@@ -108,7 +108,7 @@ public class BasicDataSource
     /**
      * The default auto-commit state of connections created by this pool.
      */
-    private volatile boolean defaultAutoCommit = true;
+    private volatile Boolean defaultAutoCommit = null;
 
     /**
      * Returns the default auto-commit property.
@@ -116,8 +116,8 @@ public class BasicDataSource
      * @return true if default auto-commit is enabled
      */
     @Override
-    public boolean getDefaultAutoCommit() {
-        return this.defaultAutoCommit;
+    public Boolean getDefaultAutoCommit() {
+        return defaultAutoCommit;
     }
 
     /**
@@ -131,7 +131,7 @@ public class BasicDataSource
      *
      * @param defaultAutoCommit default auto-commit value
      */
-    public void setDefaultAutoCommit(boolean defaultAutoCommit) {
+    public void setDefaultAutoCommit(Boolean defaultAutoCommit) {
         this.defaultAutoCommit = defaultAutoCommit;
         this.restartNeeded = true;
     }
@@ -148,15 +148,7 @@ public class BasicDataSource
      * @return true if connections are readOnly by default
      */
     @Override
-    public boolean getDefaultReadOnly() {
-        Boolean val = defaultReadOnly;
-        if (val != null) {
-            return val.booleanValue();
-        }
-        return false;
-    }
-
-    protected Boolean getDefaultReadOnlyBoolean() {
+    public Boolean getDefaultReadOnly() {
         return defaultReadOnly;
     }
 
@@ -170,8 +162,8 @@ public class BasicDataSource
      *
      * @param defaultReadOnly default read-only value
      */
-    public void setDefaultReadOnly(boolean defaultReadOnly) {
-        this.defaultReadOnly = defaultReadOnly ? Boolean.TRUE : Boolean.FALSE;
+    public void setDefaultReadOnly(Boolean defaultReadOnly) {
+        this.defaultReadOnly = defaultReadOnly;
         this.restartNeeded = true;
     }
 
@@ -2117,9 +2109,7 @@ public class BasicDataSource
             connectionFactory.setValidationQuery(validationQuery);
             connectionFactory.setValidationQueryTimeout(validationQueryTimeout);
             connectionFactory.setConnectionInitSql(connectionInitSqls);
-            if (defaultReadOnly != null) {
-                connectionFactory.setDefaultReadOnly(defaultReadOnly.booleanValue());
-            }
+            connectionFactory.setDefaultReadOnly(defaultReadOnly);
             connectionFactory.setDefaultAutoCommit(defaultAutoCommit);
             connectionFactory.setDefaultTransactionIsolation(defaultTransactionIsolation);
             connectionFactory.setDefaultCatalog(defaultCatalog);

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSourceFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSourceFactory.java?rev=1567033&r1=1567032&r2=1567033&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSourceFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSourceFactory.java
Tue Feb 11 10:31:32 2014
@@ -189,12 +189,12 @@ public class BasicDataSourceFactory impl
 
         value = properties.getProperty(PROP_DEFAULTAUTOCOMMIT);
         if (value != null) {
-            dataSource.setDefaultAutoCommit(Boolean.valueOf(value).booleanValue());
+            dataSource.setDefaultAutoCommit(Boolean.valueOf(value));
         }
 
         value = properties.getProperty(PROP_DEFAULTREADONLY);
         if (value != null) {
-            dataSource.setDefaultReadOnly(Boolean.valueOf(value).booleanValue());
+            dataSource.setDefaultReadOnly(Boolean.valueOf(value));
         }
 
         value = properties.getProperty(PROP_DEFAULTTRANSACTIONISOLATION);

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSourceMXBean.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSourceMXBean.java?rev=1567033&r1=1567032&r2=1567033&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSourceMXBean.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSourceMXBean.java
Tue Feb 11 10:31:32 2014
@@ -22,61 +22,61 @@ package org.apache.commons.dbcp2;
  * @since 2.0
  */
 public interface BasicDataSourceMXBean {
-    
+
     /**
      * See {@link BasicDataSource#getAbandonedUsageTracking()}
      * @return {@link BasicDataSource#getAbandonedUsageTracking()}
      */
     boolean getAbandonedUsageTracking();
- 
+
     /**
      * See {@link BasicDataSource#getDefaultAutoCommit()}
      * @return {@link BasicDataSource#getDefaultAutoCommit()}
      */
-    boolean getDefaultAutoCommit();
-   
+    Boolean getDefaultAutoCommit();
+
     /**
      * See {@link BasicDataSource#getDefaultReadOnly()}
      * @return {@link BasicDataSource#getDefaultReadOnly()}
      */
-    boolean getDefaultReadOnly();
-   
+    Boolean getDefaultReadOnly();
+
     /**
      * See {@link BasicDataSource#getDefaultTransactionIsolation()}
      * @return {@link BasicDataSource#getDefaultTransactionIsolation()}
      */
     int getDefaultTransactionIsolation();
-   
+
     /**
      * See {@link BasicDataSource#getDefaultCatalog()}
      * @return {@link BasicDataSource#getDefaultCatalog()}
      */
     String getDefaultCatalog();
-   
+
     /**
      * See {@link BasicDataSource#getCacheState()}
      * @return {@link BasicDataSource#getCacheState()}
      */
     boolean getCacheState();
-   
+
     /**
      * See {@link BasicDataSource#getDriverClassName()}
      * @return {@link BasicDataSource#getDriverClassName()}
      */
     String getDriverClassName();
-   
+
     /**
      * See {@link BasicDataSource#getLifo()}
      * @return {@link BasicDataSource#getLifo()}
      */
     boolean getLifo();
-   
+
     /**
      * See {@link BasicDataSource#getMaxTotal()}
      * @return {@link BasicDataSource#getMaxTotal()}
      */
     int getMaxTotal();
-   
+
     /**
      * See {@link BasicDataSource#getMaxIdle()}
      * @return {@link BasicDataSource#getMaxIdle()}
@@ -88,151 +88,151 @@ public interface BasicDataSourceMXBean {
      * @return {@link BasicDataSource#getMinIdle()}
      */
     int getMinIdle();
-   
+
     /**
      * See {@link BasicDataSource#getInitialSize()}
      * @return {@link BasicDataSource#getInitialSize()}
      */
     int getInitialSize();
-   
+
     /**
      * See {@link BasicDataSource#getMaxWaitMillis()}
      * @return {@link BasicDataSource#getMaxWaitMillis()}
      */
     long getMaxWaitMillis();
-   
+
     /**
      * See {@link BasicDataSource#isPoolPreparedStatements()}
      * @return {@link BasicDataSource#isPoolPreparedStatements()}
      */
     boolean isPoolPreparedStatements();
-   
+
     /**
      * See {@link BasicDataSource#getMaxOpenPreparedStatements()}
      * @return {@link BasicDataSource#getMaxOpenPreparedStatements()}
      */
     int getMaxOpenPreparedStatements();
-   
+
     /**
      * See {@link BasicDataSource#getTestOnBorrow()}
      * @return {@link BasicDataSource#getTestOnBorrow()}
      */
     boolean getTestOnBorrow();
-      
+
     /**
      * See {@link BasicDataSource#getTimeBetweenEvictionRunsMillis()}
      * @return {@link BasicDataSource#getTimeBetweenEvictionRunsMillis()}
      */
     long getTimeBetweenEvictionRunsMillis();
-   
+
     /**
      * See {@link BasicDataSource#getNumTestsPerEvictionRun()}
      * @return {@link BasicDataSource#getNumTestsPerEvictionRun()}
      */
     int getNumTestsPerEvictionRun();
-   
+
     /**
      * See {@link BasicDataSource#getMinEvictableIdleTimeMillis()}
      * @return {@link BasicDataSource#getMinEvictableIdleTimeMillis()}
      */
     long getMinEvictableIdleTimeMillis();
-   
+
     /**
      * See {@link BasicDataSource#getSoftMinEvictableIdleTimeMillis()}
      * @return {@link BasicDataSource#getSoftMinEvictableIdleTimeMillis()}
      */
     long getSoftMinEvictableIdleTimeMillis();
-   
+
     /**
      * See {@link BasicDataSource#getTestWhileIdle()}
      * @return {@link BasicDataSource#getTestWhileIdle()}
      */
     boolean getTestWhileIdle();
-   
+
     /**
      * See {@link BasicDataSource#getNumActive()}
      * @return {@link BasicDataSource#getNumActive()}
      */
     int getNumActive();
-   
+
     /**
      * See {@link BasicDataSource#getNumIdle()}
      * @return {@link BasicDataSource#getNumIdle()}
      */
     int getNumIdle();
-   
+
     /**
      * See {@link BasicDataSource#getPassword()}
      * @return {@link BasicDataSource#getPassword()}
      */
     String getPassword();
-   
+
     /**
      * See {@link BasicDataSource#getUrl()}
      * @return {@link BasicDataSource#getUrl()}
      */
     String getUrl();
-   
+
     /**
      * See {@link BasicDataSource#getUsername()}
      * @return {@link BasicDataSource#getUsername()}
      */
     String getUsername();
-   
+
     /**
      * See {@link BasicDataSource#getValidationQuery()}
      * @return {@link BasicDataSource#getValidationQuery()}
      */
     String getValidationQuery();
-   
+
     /**
      * See {@link BasicDataSource#getValidationQueryTimeout()}
      * @return {@link BasicDataSource#getValidationQueryTimeout()}
      */
     int getValidationQueryTimeout();
-   
+
     /**
      * See {@link BasicDataSource#getConnectionInitSqlsAsArray()}
      * @return {@link BasicDataSource#getConnectionInitSqlsAsArray()}
      */
     String[] getConnectionInitSqlsAsArray();
-   
+
     /**
      * See {@link BasicDataSource#isAccessToUnderlyingConnectionAllowed()}
      * @return {@link BasicDataSource#isAccessToUnderlyingConnectionAllowed()}
      */
     boolean isAccessToUnderlyingConnectionAllowed();
-   
+
     /**
      * See {@link BasicDataSource#getMaxConnLifetimeMillis()}
      * @return {@link BasicDataSource#getMaxConnLifetimeMillis()}
      */
     long getMaxConnLifetimeMillis();
-   
+
     /**
      * See {@link BasicDataSource#getRemoveAbandonedOnBorrow()}
      * @return {@link BasicDataSource#getRemoveAbandonedOnBorrow()}
      */
     boolean getRemoveAbandonedOnBorrow();
-   
+
     /**
      * See {@link BasicDataSource#getRemoveAbandonedOnMaintenance()}
      * @return {@link BasicDataSource#getRemoveAbandonedOnMaintenance()}
      */
     boolean getRemoveAbandonedOnMaintenance();
-   
+
     /**
      * See {@link BasicDataSource#getRemoveAbandonedTimeout()}
      * @return {@link BasicDataSource#getRemoveAbandonedTimeout()}
      */
     int getRemoveAbandonedTimeout();
-   
+
     /**
      * See {@link BasicDataSource#getLogAbandoned()}
      * @return {@link BasicDataSource#getLogAbandoned()}
      */
     boolean getLogAbandoned();
-   
+
     /**
      * See {@link BasicDataSource#isClosed()}
      * @return {@link BasicDataSource#isClosed()}

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java?rev=1567033&r1=1567032&r2=1567033&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
Tue Feb 11 10:31:32 2014
@@ -122,15 +122,15 @@ public class PoolableConnectionFactory
      * Sets the default "read only" setting for borrowed {@link Connection}s
      * @param defaultReadOnly the default "read only" setting for borrowed {@link Connection}s
      */
-    public void setDefaultReadOnly(boolean defaultReadOnly) {
-        _defaultReadOnly = defaultReadOnly ? Boolean.TRUE : Boolean.FALSE;
+    public void setDefaultReadOnly(Boolean defaultReadOnly) {
+        _defaultReadOnly = defaultReadOnly;
     }
 
     /**
      * Sets the default "auto commit" setting for borrowed {@link Connection}s
      * @param defaultAutoCommit the default "auto commit" setting for borrowed {@link Connection}s
      */
-    public void setDefaultAutoCommit(boolean defaultAutoCommit) {
+    public void setDefaultAutoCommit(Boolean defaultAutoCommit) {
         _defaultAutoCommit = defaultAutoCommit;
     }
 
@@ -317,8 +317,9 @@ public class PoolableConnectionFactory
         PoolableConnection conn = p.getObject();
         conn.activate();
 
-        if (conn.getAutoCommit() != _defaultAutoCommit) {
-            conn.setAutoCommit(_defaultAutoCommit);
+        if (_defaultAutoCommit != null &&
+                conn.getAutoCommit() != _defaultAutoCommit.booleanValue()) {
+            conn.setAutoCommit(_defaultAutoCommit.booleanValue());
         }
         if ((_defaultTransactionIsolation != UNKNOWN_TRANSACTIONISOLATION)
                 && (conn.getTransactionIsolation() !=
@@ -371,7 +372,7 @@ public class PoolableConnectionFactory
     private Collection<String> _connectionInitSqls = null;
     private volatile ObjectPool<PoolableConnection> _pool = null;
     private Boolean _defaultReadOnly = null;
-    private boolean _defaultAutoCommit = true;
+    private Boolean _defaultAutoCommit = null;
     private int _defaultTransactionIsolation = UNKNOWN_TRANSACTIONISOLATION;
     private String _defaultCatalog;
     private boolean _cacheState;

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java?rev=1567033&r1=1567032&r2=1567033&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
Tue Feb 11 10:31:32 2014
@@ -108,9 +108,9 @@ public abstract class InstanceKeyDataSou
     private String dataSourceName = null;
 
     // Default connection properties
-    private boolean defaultAutoCommit = false;
+    private Boolean defaultAutoCommit = null;
     private int defaultTransactionIsolation = UNKNOWN_TRANSACTIONISOLATION;
-    private boolean defaultReadOnly = false;
+    private Boolean defaultReadOnly = null;
 
     /** Description */
     private String description = null;
@@ -156,7 +156,6 @@ public abstract class InstanceKeyDataSou
      * Default no-arg constructor for Serialization
      */
     public InstanceKeyDataSource() {
-        defaultAutoCommit = true;
     }
 
     /**
@@ -267,11 +266,12 @@ public abstract class InstanceKeyDataSou
      * Get the value of defaultAutoCommit, which defines the state of
      * connections handed out from this pool.  The value can be changed
      * on the Connection using Connection.setAutoCommit(boolean).
-     * The default is true.
+     * The default is <code>null</code> which will use the default value for
the
+     * drive.
      *
      * @return value of defaultAutoCommit.
      */
-    public boolean isDefaultAutoCommit() {
+    public Boolean isDefaultAutoCommit() {
         return defaultAutoCommit;
     }
 
@@ -279,11 +279,12 @@ public abstract class InstanceKeyDataSou
      * Set the value of defaultAutoCommit, which defines the state of
      * connections handed out from this pool.  The value can be changed
      * on the Connection using Connection.setAutoCommit(boolean).
-     * The default is true.
+     * The default is <code>null</code> which will use the default value for
the
+     * drive.
      *
      * @param v  Value to assign to defaultAutoCommit.
      */
-    public void setDefaultAutoCommit(boolean v) {
+    public void setDefaultAutoCommit(Boolean v) {
         assertInitializationAllowed();
         this.defaultAutoCommit = v;
     }
@@ -292,11 +293,12 @@ public abstract class InstanceKeyDataSou
      * Get the value of defaultReadOnly, which defines the state of
      * connections handed out from this pool.  The value can be changed
      * on the Connection using Connection.setReadOnly(boolean).
-     * The default is false.
+     * The default is <code>null</code> which will use the default value for
the
+     * drive.
      *
      * @return value of defaultReadOnly.
      */
-    public boolean isDefaultReadOnly() {
+    public Boolean isDefaultReadOnly() {
         return defaultReadOnly;
     }
 
@@ -304,11 +306,12 @@ public abstract class InstanceKeyDataSou
      * Set the value of defaultReadOnly, which defines the state of
      * connections handed out from this pool.  The value can be changed
      * on the Connection using Connection.setReadOnly(boolean).
-     * The default is false.
+     * The default is <code>null</code> which will use the default value for
the
+     * drive.
      *
      * @param v  Value to assign to defaultReadOnly.
      */
-    public void setDefaultReadOnly(boolean v) {
+    public void setDefaultReadOnly(Boolean v) {
         assertInitializationAllowed();
         this.defaultReadOnly = v;
     }
@@ -322,7 +325,7 @@ public abstract class InstanceKeyDataSou
      * @return value of defaultTransactionIsolation.
      */
     public int getDefaultTransactionIsolation() {
-            return defaultTransactionIsolation;
+        return defaultTransactionIsolation;
     }
 
     /**

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyObjectFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyObjectFactory.java?rev=1567033&r1=1567032&r2=1567033&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyObjectFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyObjectFactory.java
Tue Feb 11 10:31:32 2014
@@ -141,14 +141,12 @@ abstract class InstanceKeyObjectFactory 
 
         ra = ref.get("defaultAutoCommit");
         if (ra != null && ra.getContent() != null) {
-            ikds.setDefaultAutoCommit(Boolean.valueOf(
-                ra.getContent().toString()).booleanValue());
+            ikds.setDefaultAutoCommit(Boolean.valueOf(ra.getContent().toString()));
         }
 
         ra = ref.get("defaultReadOnly");
         if (ra != null && ra.getContent() != null) {
-            ikds.setDefaultReadOnly(Boolean.valueOf(
-                ra.getContent().toString()).booleanValue());
+            ikds.setDefaultReadOnly(Boolean.valueOf(ra.getContent().toString()));
         }
 
         ra = ref.get("description");

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java?rev=1567033&r1=1567032&r2=1567033&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
Tue Feb 11 10:31:32 2014
@@ -496,19 +496,19 @@ public class PerUserPoolDataSource exten
     @Override
     protected void setupDefaults(Connection con, String username)
         throws SQLException {
-        boolean defaultAutoCommit = isDefaultAutoCommit();
+        Boolean defaultAutoCommit = isDefaultAutoCommit();
         if (username != null) {
             Boolean userMax = getPerUserDefaultAutoCommit(username);
             if (userMax != null) {
-                defaultAutoCommit = userMax.booleanValue();
+                defaultAutoCommit = userMax;
             }
         }
 
-        boolean defaultReadOnly = isDefaultReadOnly();
+        Boolean defaultReadOnly = isDefaultReadOnly();
         if (username != null) {
             Boolean userMax = getPerUserDefaultReadOnly(username);
             if (userMax != null) {
-                defaultReadOnly = userMax.booleanValue();
+                defaultReadOnly = userMax;
             }
         }
 
@@ -520,16 +520,18 @@ public class PerUserPoolDataSource exten
             }
         }
 
-        if (con.getAutoCommit() != defaultAutoCommit) {
-            con.setAutoCommit(defaultAutoCommit);
+        if (defaultAutoCommit != null &&
+                con.getAutoCommit() != defaultAutoCommit.booleanValue()) {
+            con.setAutoCommit(defaultAutoCommit.booleanValue());
         }
 
         if (defaultTransactionIsolation != UNKNOWN_TRANSACTIONISOLATION) {
             con.setTransactionIsolation(defaultTransactionIsolation);
         }
 
-        if (con.isReadOnly() != defaultReadOnly) {
-            con.setReadOnly(defaultReadOnly);
+        if (defaultReadOnly != null &&
+                con.isReadOnly() != defaultReadOnly.booleanValue()) {
+            con.setReadOnly(defaultReadOnly.booleanValue());
         }
     }
 

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java?rev=1567033&r1=1567032&r2=1567033&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java
Tue Feb 11 10:31:32 2014
@@ -245,9 +245,10 @@ public class SharedPoolDataSource
 
     @Override
     protected void setupDefaults(Connection con, String username) throws SQLException {
-        boolean defaultAutoCommit = isDefaultAutoCommit();
-        if (con.getAutoCommit() != defaultAutoCommit) {
-            con.setAutoCommit(defaultAutoCommit);
+        Boolean defaultAutoCommit = isDefaultAutoCommit();
+        if (defaultAutoCommit != null &&
+                con.getAutoCommit() != defaultAutoCommit.booleanValue()) {
+            con.setAutoCommit(defaultAutoCommit.booleanValue());
         }
 
         int defaultTransactionIsolation = getDefaultTransactionIsolation();
@@ -255,9 +256,10 @@ public class SharedPoolDataSource
             con.setTransactionIsolation(defaultTransactionIsolation);
         }
 
-        boolean defaultReadOnly = isDefaultReadOnly();
-        if (con.isReadOnly() != defaultReadOnly) {
-            con.setReadOnly(defaultReadOnly);
+        Boolean defaultReadOnly = isDefaultReadOnly();
+        if (defaultReadOnly != null &&
+                con.isReadOnly() != defaultReadOnly.booleanValue()) {
+            con.setReadOnly(defaultReadOnly.booleanValue());
         }
     }
 

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java?rev=1567033&r1=1567032&r2=1567033&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java
Tue Feb 11 10:31:32 2014
@@ -188,9 +188,7 @@ public class BasicManagedDataSource exte
             connectionFactory.setValidationQuery(getValidationQuery());
             connectionFactory.setValidationQueryTimeout(getValidationQueryTimeout());
             connectionFactory.setConnectionInitSql(getConnectionInitSqls());
-            if (getDefaultReadOnlyBoolean() != null) {
-                connectionFactory.setDefaultReadOnly(getDefaultReadOnly());
-            }
+            connectionFactory.setDefaultReadOnly(getDefaultReadOnly());
             connectionFactory.setDefaultAutoCommit(getDefaultAutoCommit());
             connectionFactory.setDefaultTransactionIsolation(getDefaultTransactionIsolation());
             connectionFactory.setDefaultCatalog(getDefaultCatalog());

Modified: commons/proper/dbcp/trunk/src/site/xdoc/configuration.xml
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/site/xdoc/configuration.xml?rev=1567033&r1=1567032&r2=1567033&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/site/xdoc/configuration.xml (original)
+++ commons/proper/dbcp/trunk/src/site/xdoc/configuration.xml Tue Feb 11 10:31:32 2014
@@ -81,8 +81,10 @@ testWhileIdle
 <hr><th>Parameter</th><th>Default</th><th>Description</th></hr>
 <tr>
    <td>defaultAutoCommit</td>
-   <td>true</td>
-   <td>The default auto-commit state of connections created by this pool.</td>
+   <td>driver default</td>
+   <td>The default auto-commit state of connections created by this pool.
+       If not set then the setAutoCommit method will not be called.
+   </td>
 </tr>
 <tr>
    <td>defaultReadOnly</td>

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java?rev=1567033&r1=1567032&r2=1567033&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java
Tue Feb 11 10:31:32 2014
@@ -92,8 +92,8 @@ public class TestBasicDataSourceFactory 
         assertEquals(500, ds.getMaxWaitMillis());
         assertEquals(5, ds.getInitialSize());
         assertEquals(5, ds.getNumIdle());
-        assertEquals(true, ds.getDefaultAutoCommit());
-        assertEquals(false, ds.getDefaultReadOnly());
+        assertEquals(Boolean.TRUE, ds.getDefaultAutoCommit());
+        assertEquals(Boolean.FALSE, ds.getDefaultReadOnly());
         assertEquals(Connection.TRANSACTION_READ_COMMITTED, ds.getDefaultTransactionIsolation());
         assertEquals("test", ds.getDefaultCatalog());
         assertEquals(true, ds.getTestOnBorrow());

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java?rev=1567033&r1=1567032&r2=1567033&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java
Tue Feb 11 10:31:32 2014
@@ -74,7 +74,7 @@ public class TestPerUserPoolDataSource e
         tds.setPerUserMaxWaitMillis("foo", Integer.valueOf((int)(getMaxWaitMillis())));
         tds.setDefaultTransactionIsolation(
             Connection.TRANSACTION_READ_COMMITTED);
-
+        tds.setDefaultAutoCommit(Boolean.TRUE);
         ds = tds;
     }
 



Mime
View raw message