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 km...@apache.org on 2006/02/23 00:57:33 UTC
svn commit: r379993 - in /db/derby/code/trunk/java:
client/org/apache/derby/client/am/
testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/
testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/
Author: kmarsden
Date: Wed Feb 22 15:57:30 2006
New Revision: 379993
URL: http://svn.apache.org/viewcvs?rev=379993&view=rev
Log:
DERBY-1010 - setTransactionIsolation can cause ava.sql.SQLException: Invalid operation: statement closed in some contexts with xa
Client has a Statement object that it reuses to send SET CURRENT ISOLATION commands to the server. Added a check to make sure this statement was not closed before trying to reuse it.
This change takes the checkDataSource test a bit further (DERBY-435) but there seem to be issues with isolation being set correctly with xa_join. I will investigate that and file a Jira issue
Added:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out (with props)
Modified:
db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.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/am/Connection.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java?rev=379993&r1=379992&r2=379993&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 Wed Feb 22 15:57:30 2006
@@ -902,7 +902,9 @@
"Transaction isolation level " + level + " is an invalid argument for java.sql.Connection.setTransactionIsolation()." +
" See Javadoc specification for a list of valid arguments.", "XJ045");
}
- if (setTransactionIsolationStmt == null) {
+ if (setTransactionIsolationStmt == null ||
+ !(setTransactionIsolationStmt.openOnClient_ &&
+ setTransactionIsolationStmt.openOnServer_)) {
setTransactionIsolationStmt =
createStatementX(java.sql.ResultSet.TYPE_FORWARD_ONLY,
java.sql.ResultSet.CONCUR_READ_ONLY,
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out?rev=379993&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out Wed Feb 22 15:57:30 2006
@@ -0,0 +1,397 @@
+Running connection checks on DriverManager
+ isolation level 2
+ auto commit true
+ read only false
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+method calls on a closed connection
+DriverManager <closedconn>.close() no error
+DriverManager <closedconn>.createStatement() null - invalid operation: connection closed
+DriverManager <closedstmt>.execute() null - Invalid operation: statement closed
+Running connection checks on DataSource
+ isolation level 2
+ auto commit true
+ read only false
+ has warnings false
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+method calls on a closed connection
+DataSource <closedconn>.close() no error
+DataSource <closedconn>.createStatement() null - invalid operation: connection closed
+DataSource <closedstmt>.execute() null - Invalid operation: statement closed
+Running connection checks on ConnectionPoolDataSource
+ isolation level 2
+ auto commit true
+ read only false
+ has warnings false
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for DatabaseMetaData.getConnection()
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+EVENT(1):connectionClosed
+method calls on a closed connection
+ConnectionPoolDataSource <closedconn>.close() no error
+ConnectionPoolDataSource <closedconn>.createStatement() 08003 - No current connection.
+ConnectionPoolDataSource <closedstmt>.execute() null - Invalid operation: statement closed
+Running connection checks on ConnectionPoolDataSource
+ isolation level 2
+ auto commit true
+ read only false
+ has warnings false
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for DatabaseMetaData.getConnection()
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+EVENT(1):connectionClosed
+method calls on a closed connection
+ConnectionPoolDataSource <closedconn>.close() no error
+ConnectionPoolDataSource <closedconn>.createStatement() 08003 - No current connection.
+ConnectionPoolDataSource <closedstmt>.execute() null - Invalid operation: statement closed
+Changes rolled back OK in auto closed pooled connection
+EVENT(1):connectionClosed
+expected java.sql.SQLException: Invalid operation: result set closed
+expected java.sql.SQLException: Invalid operation: statement closed
+Start testPoolReset ConnectionPoolDataSource
+IDENTITY_VAL_LOCAL=1
+IDENTITY_VAL_LOCAL=2
+IDENTITY_VAL_LOCAL=3
+End testPoolReset ConnectionPoolDataSource
+Running connection checks on XADataSource
+ isolation level 2
+ auto commit true
+ read only false
+ has warnings false
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for DatabaseMetaData.getConnection()
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+EVENT(3):connectionClosed
+method calls on a closed connection
+XADataSource <closedconn>.close() no error
+XADataSource <closedconn>.createStatement() 08003 - No current connection.
+XADataSource <closedstmt>.execute() null - Invalid operation: statement closed
+Changes rolled back OK in auto closed local XAConnection
+EVENT(3):connectionClosed
+Start testPoolReset XADataSource
+IDENTITY_VAL_LOCAL=1
+IDENTITY_VAL_LOCAL=2
+IDENTITY_VAL_LOCAL=3
+End testPoolReset XADataSource
+ERROR XJ015: Derby system shutdown.
+Running connection checks on DriverManager
+ isolation level 2
+ auto commit true
+ read only false
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+method calls on a closed connection
+DriverManager <closedconn>.close() no error
+DriverManager <closedconn>.createStatement() null - invalid operation: connection closed
+DriverManager <closedstmt>.execute() null - Invalid operation: statement closed
+Running connection checks on DataSource
+ isolation level 2
+ auto commit true
+ read only false
+ has warnings false
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+method calls on a closed connection
+DataSource <closedconn>.close() no error
+DataSource <closedconn>.createStatement() null - invalid operation: connection closed
+DataSource <closedstmt>.execute() null - Invalid operation: statement closed
+Running connection checks on ConnectionPoolDataSource
+ isolation level 2
+ auto commit true
+ read only false
+ has warnings false
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for DatabaseMetaData.getConnection()
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+EVENT(2):connectionClosed
+method calls on a closed connection
+ConnectionPoolDataSource <closedconn>.close() no error
+ConnectionPoolDataSource <closedconn>.createStatement() 08003 - No current connection.
+ConnectionPoolDataSource <closedstmt>.execute() null - Invalid operation: statement closed
+Running connection checks on ConnectionPoolDataSource
+ isolation level 2
+ auto commit true
+ read only false
+ has warnings false
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for DatabaseMetaData.getConnection()
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+EVENT(2):connectionClosed
+method calls on a closed connection
+ConnectionPoolDataSource <closedconn>.close() no error
+ConnectionPoolDataSource <closedconn>.createStatement() 08003 - No current connection.
+ConnectionPoolDataSource <closedstmt>.execute() null - Invalid operation: statement closed
+Running connection checks on XADataSource
+ isolation level 2
+ auto commit true
+ read only false
+ has warnings false
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for DatabaseMetaData.getConnection()
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+EVENT(4):connectionClosed
+method calls on a closed connection
+XADataSource <closedconn>.close() no error
+XADataSource <closedconn>.createStatement() 08003 - No current connection.
+XADataSource <closedstmt>.execute() null - Invalid operation: statement closed
+Running connection checks on XADataSource
+ isolation level 2
+ auto commit true
+ read only false
+ has warnings false
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for DatabaseMetaData.getConnection()
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+EVENT(4):connectionClosed
+method calls on a closed connection
+XADataSource <closedconn>.close() no error
+XADataSource <closedconn>.createStatement() 08003 - No current connection.
+XADataSource <closedstmt>.execute() null - Invalid operation: statement closed
+EVENT(5):connectionClosed
+Running connection checks on Global XADataSource
+ isolation level 2
+ auto commit false
+ read only false
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for DatabaseMetaData.getConnection()
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+EVENT(5):connectionClosed
+method calls on a closed connection
+Global XADataSource <closedconn>.close() no error
+Global XADataSource <closedconn>.createStatement() 08003 - No current connection.
+Global XADataSource <closedstmt>.execute() null - Invalid operation: statement closed
+Running connection checks on Global XADataSource
+ isolation level 2
+ auto commit false
+ read only false
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for DatabaseMetaData.getConnection()
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+EVENT(5):connectionClosed
+method calls on a closed connection
+Global XADataSource <closedconn>.close() no error
+Global XADataSource <closedconn>.createStatement() 08003 - No current connection.
+Global XADataSource <closedstmt>.execute() null - Invalid operation: statement closed
+Running connection checks on Switch to local XADataSource
+ isolation level 2
+ auto commit true
+ read only false
+ has warnings false
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for DatabaseMetaData.getConnection()
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+EVENT(5):connectionClosed
+method calls on a closed connection
+Switch to local XADataSource <closedconn>.close() no error
+Switch to local XADataSource <closedconn>.createStatement() 08003 - No current connection.
+Switch to local XADataSource <closedstmt>.execute() null - Invalid operation: statement closed
+Running connection checks on Switch to local XADataSource
+ isolation level 2
+ auto commit true
+ read only false
+ has warnings false
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for DatabaseMetaData.getConnection()
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+EVENT(5):connectionClosed
+method calls on a closed connection
+Switch to local XADataSource <closedconn>.close() no error
+Switch to local XADataSource <closedconn>.createStatement() 08003 - No current connection.
+Switch to local XADataSource <closedstmt>.execute() null - Invalid operation: statement closed
+Running connection checks on Switch to global XADataSource
+ isolation level 2
+ auto commit false
+ read only false
+ has warnings false
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for DatabaseMetaData.getConnection()
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+EVENT(5):connectionClosed
+method calls on a closed connection
+Switch to global XADataSource <closedconn>.close() no error
+Switch to global XADataSource <closedconn>.createStatement() 08003 - No current connection.
+Switch to global XADataSource <closedstmt>.execute() null - Invalid operation: statement closed
+Running connection checks on Switch to global XADataSource
+ isolation level 2
+ auto commit false
+ read only false
+ has warnings false
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for Statement.getConnection()
+FAIL incorrect connection object returned for DatabaseMetaData.getConnection()
+setTypeMap(EMPTY_MAP) - FAIL null - Connection.setTypeMap is not supported
+setTypeMap(null) - ok null - Connection.setTypeMap is not supported
+setTypeMap(map) - ok null - Connection.setTypeMap is not supported
+EVENT(5):connectionClosed
+method calls on a closed connection
+Switch to global XADataSource <closedconn>.close() no error
+Switch to global XADataSource <closedconn>.createStatement() 08003 - No current connection.
+Switch to global XADataSource <closedstmt>.execute() null - Invalid operation: statement closed
+initial local
+ isolation level READ_COMMITTED
+ auto commit true
+ read only false
+initial X1
+ isolation level READ_COMMITTED
+ auto commit false
+ read only false
+modified X1
+ isolation level READ_UNCOMMITTED
+ auto commit false
+ read only false
+modified local
+ isolation level READ_UNCOMMITTED
+ auto commit true
+ read only false
+reset local
+ isolation level READ_COMMITTED
+ auto commit true
+ read only false
+re-join X1
+ isolation level READ_COMMITTED
+ auto commit false
+ read only false
+back to local (same as reset)
+ isolation level READ_COMMITTED
+ auto commit true
+ read only false
+EVENT(6):connectionClosed
+new handle - local
+ isolation level READ_UNCOMMITTED
+ auto commit true
+ read only false
+EVENT(6):connectionClosed
+re-join with new handle X1
+ isolation level READ_UNCOMMITTED
+ auto commit false
+ read only false
+EVENT(6):connectionClosed
+pre-X1 commit - local
+ isolation level REPEATABLE_READ
+ auto commit true
+ read only false
+pre-X1 commit - X1
+ isolation level REPEATABLE_READ
+ auto commit false
+ read only false
+post-X1 end - local
+ isolation level REPEATABLE_READ
+ auto commit true
+ read only false
+post-X1 commit - local
+ isolation level REPEATABLE_READ
+ auto commit true
+ read only false
+EVENT(6):connectionClosed
+Some more isolation testing using SQL and JDBC api
+initial local
+ isolation level REPEATABLE_READ
+ auto commit true
+ read only false
+Issue setTransactionIsolation in local transaction
+setTransactionIsolation in local
+ isolation level READ_UNCOMMITTED
+ auto commit true
+ read only false
+Issue SQL to change isolation in local transaction
+SQL to change isolation in local
+ isolation level READ_UNCOMMITTED
+ auto commit true
+ read only false
+1st global(new)
+ isolation level READ_UNCOMMITTED
+ auto commit false
+ read only false
+local
+ isolation level READ_UNCOMMITTED
+ auto commit true
+ read only false
+Issue SQL to change isolation in local transaction
+SQL to change isolation in local
+ isolation level READ_UNCOMMITTED
+ auto commit true
+ read only false
+2nd global(new)
+ isolation level READ_UNCOMMITTED
+ auto commit false
+ read only false
+1st global(existing)
+ isolation level READ_UNCOMMITTED
+ auto commit false
+ read only false
+local
+ isolation level READ_UNCOMMITTED
+ auto commit true
+ read only false
+1st global(existing)
+ isolation level READ_UNCOMMITTED
+ auto commit false
+ read only false
+Issue SQL to change isolation in 1st global transaction
+change isolation of existing 1st global transaction
+ isolation level READ_UNCOMMITTED
+ auto commit false
+ read only false
+local
+ isolation level READ_UNCOMMITTED
+ auto commit true
+ read only false
+2nd global(existing)
+ isolation level READ_UNCOMMITTED
+ auto commit false
+ read only false
+(After 2nd global rollback) local
+ isolation level READ_UNCOMMITTED
+ auto commit true
+ read only false
+(After 1st global rollback) local
+ isolation level READ_UNCOMMITTED
+ auto commit true
+ read only false
+TESTING RE_USE OF STATEMENT OBJECTS
+THE STATEMENT OBJECTS CAN NOT BE REUSED ACROSS LOCAL/GLOBAL CONNECTIONS BECAUSE, LOCAL CONNECTION CREATES THEM
+WITH HOLDABILITY TRUE WHEREAS GLOBAL CONNECTION CAN ONLY WORK WITH STATEMENTS WITH HOLDABILITY FALSE
+LOCK TABLE
+END LOCK TABLE
+Completed checkDataSource
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java?rev=379993&r1=379992&r2=379993&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 Wed Feb 22 15:57:30 2006
@@ -111,12 +111,7 @@
*/
private final Object nogc = SecurityCheck.class;
- // setTransactionIsolation in some contexts used in this test is
- // causing java.sql.SQLException: Invalid operation: statement closed
- // error on client. These cases are omitted for now where they cause the
- // statement closed error
- private static boolean causesStmtClosedOnSetTransactionIsolation = TestUtil.isDerbyNetClientFramework();
-
+
public static void main(String[] args) throws Exception {
try
@@ -368,8 +363,7 @@
printState("initial local", cs1);
xar.start(xid, XAResource.TMNOFLAGS);
printState("initial X1", cs1);
- if (!causesStmtClosedOnSetTransactionIsolation)
- cs1.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
+ cs1.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
cs1.setReadOnly(true);
setHoldability(cs1, false);
printState("modified X1", cs1);
@@ -413,10 +407,7 @@
// attach to the global and commit it.
// state should be that of the local after the commit.
cs1 = xac.getConnection();
- if (! causesStmtClosedOnSetTransactionIsolation)
- {
- cs1.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
- }
+ cs1.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
printState("pre-X1 commit - local", cs1);
xar.start(xid, XAResource.TMJOIN);
printState("pre-X1 commit - X1", cs1);
@@ -492,6 +483,11 @@
cs1.setAutoCommit(false);
checkLocks(cs1);
+ // For client the test only runs this far
+ // More DERBY-435 checkins will take it further.
+ if (TestUtil.isDerbyNetClientFramework())
+ return;
+
Statement sru1 = cs1.createStatement();
sru1.setCursorName("SN1");
sru1.executeUpdate("create table ru(i int)");