You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by da...@apache.org on 2006/06/08 22:40:14 UTC
svn commit: r412852 - in /db/derby/code/trunk/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/tests/jdbcapi/
Author: davidvc
Date: Thu Jun 8 13:40:13 2006
New Revision: 412852
URL: http://svn.apache.org/viewvc?rev=412852&view=rev
Log:
DERBY-1004: Client should not require user to rollback the active transaction before call to PooledConnection.getConnection()
Modified:
db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java?rev=412852&r1=412851&r2=412852&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java Thu Jun 8 13:40:13 2006
@@ -178,7 +178,7 @@
{
if (logWriter_ != null) {
logWriter_.traceEntry(this, "getConnection");
- }
+ }
createLogicalConnection();
@@ -210,6 +210,19 @@
throw new SqlException(logWriter_,
new ClientMessageId(SQLState.NOGETCONN_ON_CLOSED_POOLED_CONNECTION));
}
+
+ // 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
+ // (this fixes DERBY-1004)
+ try {
+ if ( physicalConnection_.transactionInProgress() ) {
+ physicalConnection_.rollback();
+ }
+ } catch ( SQLException sqle ) {
+ throw new SqlException(sqle);
+ }
+
// 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/trunk/java/client/org/apache/derby/client/am/Connection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java?rev=412852&r1=412851&r2=412852&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java Thu Jun 8 13:40:13 2006
@@ -714,10 +714,14 @@
void checkForTransactionInProgress() throws SqlException {
// The following precondition matches CLI semantics, see SQLDisconnect()
- if (!autoCommit_ && inUnitOfWork_ && !allowCloseInUOW_()) {
+ if (transactionInProgress() && !allowCloseInUOW_()) {
throw new SqlException(agent_.logWriter_,
new ClientMessageId (SQLState.CANNOT_CLOSE_ACTIVE_CONNECTION));
}
+ }
+
+ public boolean transactionInProgress() {
+ return !autoCommit_ && inUnitOfWork_;
}
// This is a no-op if the connection is already closed.
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out?rev=412852&r1=412851&r2=412852&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out Thu Jun 8 13:40:13 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/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java?rev=412852&r1=412851&r2=412852&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java Thu Jun 8 13:40:13 2006
@@ -637,12 +637,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
xa_getconnection;
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java?rev=412852&r1=412851&r2=412852&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java Thu Jun 8 13:40:13 2006
@@ -73,14 +73,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();
@@ -213,8 +205,6 @@
// this update should be rolled back
s.executeUpdate("insert into t values(2)");
- if (needRollbackBeforePCGetConnection)
- c1.rollback();
c1 = pc.getConnection();
@@ -268,8 +258,6 @@
// this update should be rolled back
s.executeUpdate("insert into t values(2)");
- if (needRollbackBeforePCGetConnection)
- c1.rollback();
c1 = xac.getConnection();