db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davi...@apache.org
Subject svn commit: r412860 - in /db/derby/code/branches/10.1/java: client/org/apache/derby/client/ client/org/apache/derby/client/am/ testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/ testing/org/apache/derbyTesting/functionTests/test...
Date Thu, 08 Jun 2006 21:30:01 GMT
Author: davidvc
Date: Thu Jun  8 14:30:00 2006
New Revision: 412860

URL: http://svn.apache.org/viewvc?rev=412860&view=rev
Log:
DERBY-1004: Client should not require user to rollback the active transaction before call
to PooledConnection.getConnection()


Modified:
    db/derby/code/branches/10.1/java/client/org/apache/derby/client/ClientPooledConnection.java
    db/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java

Modified: db/derby/code/branches/10.1/java/client/org/apache/derby/client/ClientPooledConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/client/org/apache/derby/client/ClientPooledConnection.java?rev=412860&r1=412859&r2=412860&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/client/org/apache/derby/client/ClientPooledConnection.java
(original)
+++ db/derby/code/branches/10.1/java/client/org/apache/derby/client/ClientPooledConnection.java
Thu Jun  8 14:30:00 2006
@@ -160,6 +160,15 @@
         if (physicalConnection_ == null) {
             throw new SqlException(logWriter_, "getConnection() is not valid on a closed
PooledConnection.");
         }
+        
+        // Roll back any pending transactions.  Otherwise we get an exception 
+        // when we try to close the connection (even for re-use), with an error
+        // saying we can't close the connection with active transactions
+        // (fixes DERBY-1004)
+        if ( physicalConnection_.transactionInProgress() ) {
+            physicalConnection_.rollback();
+        }
+        
         // Not the usual case, but if we have an existing logical connection, then we must
close it by spec.
         // We close the logical connection without notifying the pool manager that this pooled
connection is availabe for reuse.
         if (logicalConnection_ != null) {

Modified: db/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java?rev=412860&r1=412859&r2=412860&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java (original)
+++ db/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java Thu
Jun  8 14:30:00 2006
@@ -652,13 +652,17 @@
 
     void checkForTransactionInProgress() throws SqlException {
         // The following precondition matches CLI semantics, see SQLDisconnect()
-        if (!autoCommit_ && inUnitOfWork_ && !allowCloseInUOW_()) {
+        if ( transactionInProgress() && !allowCloseInUOW_()) {
             throw new SqlException(agent_.logWriter_,
                     "java.sql.Connection.close() requested while a transaction is in progress
on the connection." +
                     "The transaction remains active, and the connection cannot be closed.");
         }
     }
 
+    public boolean transactionInProgress() {
+        return !autoCommit_ && inUnitOfWork_;
+    }
+    
     // This is a no-op if the connection is already closed.
     synchronized public void closeX() throws SqlException {
         if (!open_) {

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out?rev=412860&r1=412859&r2=412860&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
Thu Jun  8 14:30:00 2006
@@ -48,7 +48,6 @@
 2001       
 2002       
 2003       
-DERBY-1004 Call conn.close to avoid exception with client
 GXID |STATUS |READONLY |USERNAME |TYPE                          
 -----
 (1 |PREPARED |false |APP |UserTransaction               

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java?rev=412860&r1=412859&r2=412860&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
Thu Jun  8 14:30:00 2006
@@ -620,11 +620,6 @@
 
             xar.end(xid2, XAResource.TMSUSPEND);
 
-            // DERBY-1004
-            if (TestUtil.isDerbyNetClientFramework()) {
-                System.out.println("DERBY-1004 Call conn.close to avoid exception with client");
-                conn.close();
-            }
 
             /*
              -- get local connection again

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java?rev=412860&r1=412859&r2=412860&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
Thu Jun  8 14:30:00 2006
@@ -61,14 +61,6 @@
 	// Only embedded supports SimpleDataSource (JSR169).  
 	// These tests are exempted from other frameworks
 	private boolean testSimpleDataSource = TestUtil.isEmbeddedFramework();
-
-	// for a PooledConnection.getConnection() the connection gets closed.
-	// Embedded automatically rolls back any activity on the connection.
-	// Client requires the user to rollback and gives an SQLException  
-	// java.sql.Connection.close() requested while a transaction is in progress
-	// This has been filed as DERBY-1004 
-	private  boolean needRollbackBeforePCGetConnection = 
-		TestUtil.isDerbyNetClientFramework(); 
 	
 	// DERBY-1183 getCursorName not correct after first statement execution
 	private static boolean hasGetCursorNameBug = TestUtil.isDerbyNetClientFramework();
@@ -181,8 +173,6 @@
 
 		// this update should be rolled back
 		s.executeUpdate("insert into t values(2)");
-		if (needRollbackBeforePCGetConnection)
-			c1.rollback();
 		
 		c1 = pc.getConnection();
 
@@ -235,8 +225,6 @@
 
 		// this update should be rolled back
 		s.executeUpdate("insert into t values(2)");
-		if (needRollbackBeforePCGetConnection)
-			c1.rollback();
 		
 		c1 = xac.getConnection();
 



Mime
View raw message