In some drivers, the call to setTransactionIsolation should be the very first call
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 19 Feb 2010 23:02:49 +0000 (23:02 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 19 Feb 2010 23:02:49 +0000 (23:02 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@912026 13f79535-47bb-0310-9956-ffa450edef68

modules/jdbc-pool/.classpath
modules/jdbc-pool/build.xml
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/ConnectionState.java

index c82296b..6983e0d 100644 (file)
@@ -6,6 +6,5 @@
        <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
        <classpathentry kind="var" path="TOMCAT_LIBS_BASE/tomcat6-deps/dbcp/tomcat-dbcp.jar" sourcepath="/TOMCAT_LIBS_BASE/tomcat6-deps/dbcp/src/java"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-       <classpathentry kind="lib" path="/development/tomcat/trunk/trunk/modules/jdbc-pool/includes/h2/bin/h2-1.1.118.jar"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
index b1373b0..cebdd99 100644 (file)
     <delete file="${base.path}/file.zip"/>
   </target>
   
-  <target name="download">
+  <target name="download" unless="skip.download">
     <mkdir dir="${base.path}"/>
 <!-- 
     <antcall target="downloadzip">
index 2720f35..b27a229 100644 (file)
@@ -159,10 +159,10 @@ public class PooledConnection {
         
         //set up the default state, unless we expect the interceptor to do it
         if (poolProperties.getJdbcInterceptors()==null || poolProperties.getJdbcInterceptors().indexOf(ConnectionState.class.getName())<0) {
+            if (poolProperties.getDefaultTransactionIsolation()!=DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION) connection.setTransactionIsolation(poolProperties.getDefaultTransactionIsolation());
             if (poolProperties.getDefaultReadOnly()!=null) connection.setReadOnly(poolProperties.getDefaultReadOnly().booleanValue());
             if (poolProperties.getDefaultAutoCommit()!=null) connection.setAutoCommit(poolProperties.getDefaultAutoCommit().booleanValue());
             if (poolProperties.getDefaultCatalog()!=null) connection.setCatalog(poolProperties.getDefaultCatalog());
-            if (poolProperties.getDefaultTransactionIsolation()!=DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION) connection.setTransactionIsolation(poolProperties.getDefaultTransactionIsolation());
         }        
         this.discarded = false;
         this.lastConnected = System.currentTimeMillis();
index d0718a0..a56d969 100644 (file)
@@ -56,6 +56,17 @@ public class ConnectionState extends JdbcInterceptor  {
     public void reset(ConnectionPool parent, PooledConnection con) {
         if (parent==null || con==null) return;
         PoolConfiguration poolProperties = parent.getPoolProperties();
+        if (poolProperties.getDefaultTransactionIsolation()!=DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION) {
+            try {
+                if (transactionIsolation==null || transactionIsolation.intValue()!=poolProperties.getDefaultTransactionIsolation()) {
+                    con.getConnection().setTransactionIsolation(poolProperties.getDefaultTransactionIsolation());
+                    transactionIsolation = Integer.valueOf(poolProperties.getDefaultTransactionIsolation());
+                }
+            }catch (SQLException x) {
+                transactionIsolation = null;
+                log.error("Unable to reset transaction isolation state to connection.",x);
+            }
+        }
         if (poolProperties.getDefaultReadOnly()!=null) {
             try {
                 if (readOnly==null || readOnly.booleanValue()!=poolProperties.getDefaultReadOnly().booleanValue()) {
@@ -89,17 +100,7 @@ public class ConnectionState extends JdbcInterceptor  {
                 log.error("Unable to reset default catalog state to connection.",x);
             }
         }
-        if (poolProperties.getDefaultTransactionIsolation()!=DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION) {
-            try {
-                if (transactionIsolation==null || transactionIsolation.intValue()!=poolProperties.getDefaultTransactionIsolation()) {
-                    con.getConnection().setTransactionIsolation(poolProperties.getDefaultTransactionIsolation());
-                    transactionIsolation = Integer.valueOf(poolProperties.getDefaultTransactionIsolation());
-                }
-            }catch (SQLException x) {
-                transactionIsolation = null;
-                log.error("Unable to reset transaction isolation state to connection.",x);
-            }
-        }
+        
     }
 
     @Override