Index: java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java =================================================================== --- java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java (revision 191099) +++ java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java (working copy) @@ -33,12 +33,21 @@ import java.io.ObjectOutput; import java.io.ObjectInput; +import java.lang.reflect.*; + +import org.apache.derby.iapi.reference.JDBC30Translation; +import org.apache.derby.iapi.error.PublicAPI; +import org.apache.derby.iapi.error.StandardException; + /** * This is a rudimentary connection that delegates * EVERYTHING to Connection. */ public class BrokeredConnection implements Connection { + + // default for Derby + protected int stateHoldability = JDBC30Translation.HOLD_CURSORS_OVER_COMMIT; protected final BrokeredConnectionControl control; private boolean isClosed; @@ -383,6 +392,15 @@ stateIsolationLevel = conn.getTransactionIsolation(); stateReadOnly = conn.isReadOnly(); stateAutoCommit = conn.getAutoCommit(); + // jdk13 does not have Connection.getHoldability method and hence using + // reflection to cover both jdk13 and higher jdks + try { + Method sh = conn.getClass().getMethod("getHoldability", null); + stateHoldability = ((Integer)sh.invoke(conn, null)).intValue(); + } catch( Exception e) + { + throw PublicAPI.wrapStandardException( StandardException.plainWrapException( e)); + } } /** @@ -396,6 +414,8 @@ */ public void setState(boolean complete) throws SQLException { + Class[] CONN_PARAM = { Integer.TYPE }; + Object[] CONN_ARG = { new Integer(stateHoldability)}; Connection conn = getRealConnection(); @@ -403,6 +423,18 @@ conn.setTransactionIsolation(stateIsolationLevel); conn.setReadOnly(stateReadOnly); conn.setAutoCommit(stateAutoCommit); + // make the underlying connection pick my holdability state + // since holdability is a state of the connection handle + // not the underlying transaction. + // jdk13 does not have Connection.setHoldability method and hence using + // reflection to cover both jdk13 and higher jdks + try { + Method sh = conn.getClass().getMethod("setHoldability", CONN_PARAM); + sh.invoke(conn, CONN_ARG); + } catch( Exception e) + { + throw PublicAPI.wrapStandardException( StandardException.plainWrapException( e)); + } } } Index: java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection30.java =================================================================== --- java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection30.java (revision 191099) +++ java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection30.java (working copy) @@ -32,9 +32,6 @@ */ public class BrokeredConnection30 extends BrokeredConnection { - - // default for Cloudscape - private int stateHoldability = java.sql.ResultSet.HOLD_CURSORS_OVER_COMMIT; public BrokeredConnection30(BrokeredConnectionControl control) { @@ -216,20 +213,7 @@ throw se; } } - public void syncState() throws SQLException { - super.syncState(); - // make the underlying connection pick my holdability state - // since holdability is a state of the connection handle - // not the underlying transaction. - getRealConnection().setHoldability(stateHoldability); - } - public void setState(boolean complete) throws SQLException { - super.setState(complete); - if (complete) - getRealConnection().setHoldability(stateHoldability); - } - public BrokeredPreparedStatement newBrokeredStatement(BrokeredStatementControl statementControl, String sql, Object generatedKeys) throws SQLException { return new BrokeredPreparedStatement30(statementControl, getJDBCLevel(), sql, generatedKeys); } Index: java/testing/org/apache/derbyTesting/functionTests/tests/store/xaOffline1.sql =================================================================== --- java/testing/org/apache/derbyTesting/functionTests/tests/store/xaOffline1.sql (revision 191099) +++ java/testing/org/apache/derbyTesting/functionTests/tests/store/xaOffline1.sql (working copy) @@ -7,12 +7,6 @@ xa_connect ; xa_start xa_noflags 0; xa_getconnection; --- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; drop table foo; create table foo (a int); insert into foo values (0); @@ -70,12 +64,6 @@ xa_start xa_noflags 4; xa_getconnection; --- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; select * from global_xactTable where gxid is not null order by gxid; select * from lock_table order by tabname, type desc, mode, cnt, lockname; xa_recover xa_startrscan; Index: java/testing/org/apache/derbyTesting/functionTests/tests/store/xab2354.sql =================================================================== --- java/testing/org/apache/derbyTesting/functionTests/tests/store/xab2354.sql (revision 191099) +++ java/testing/org/apache/derbyTesting/functionTests/tests/store/xab2354.sql (working copy) @@ -2,12 +2,6 @@ xa_connect; xa_start xa_noflags 1; xa_getconnection; --- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; create table foo (a int); insert into foo values (1); xa_end xa_success 1; Index: java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/xaAnotherTest.sql =================================================================== --- java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/xaAnotherTest.sql (revision 191099) +++ java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/xaAnotherTest.sql (working copy) @@ -8,12 +8,6 @@ xa_connect ; xa_start xa_noflags 0; xa_getconnection; --- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; drop table APP.foo; create table APP.foo (a int); insert into APP.foo values (0); @@ -34,12 +28,6 @@ -- global connection 1 xa_start xa_noflags 1; xa_getconnection; --- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; insert into APP.foo values (1); xa_end xa_suspend 1; @@ -128,12 +116,6 @@ -- add couple more global transactions xa_start xa_noflags 6; xa_getconnection; --- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; insert into APP.foo values (6); xa_end xa_suspend 6; Index: java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/xaSimplePositive.sql =================================================================== --- java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/xaSimplePositive.sql (revision 191099) +++ java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/xaSimplePositive.sql (working copy) @@ -6,12 +6,6 @@ xa_connect ; xa_start xa_noflags 0; xa_getconnection; --- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; drop table foo; create table foo (a int); insert into foo values (0); @@ -31,12 +25,6 @@ xa_start xa_noflags 1; xa_getconnection; --- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; insert into APP.foo values (1); xa_end xa_suspend 1; @@ -111,12 +99,6 @@ xa_start xa_resume 4; xa_getconnection; --- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; insert into APP.foo values (4); disconnect; @@ -136,12 +118,6 @@ xa_start xa_resume 5; xa_getconnection; --- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; insert into APP.foo values (5); xa_end xa_success 5; Index: java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/xaSimpleNegative.sql =================================================================== --- java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/xaSimpleNegative.sql (revision 191099) +++ java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/xaSimpleNegative.sql (working copy) @@ -11,12 +11,6 @@ xa_start xa_noflags 1; xa_getconnection; --- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; -- ERROR: cannot get connection again xa_getconnection; @@ -79,12 +73,6 @@ xa_start xa_noflags 2; xa_getconnection; --- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; insert into APP.negative values ('ok', 3); @@ -117,12 +105,6 @@ -- this is OK xa_start xa_join 2; xa_getconnection; --- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; -- ERROR: another dup insert into APP.negative values ('rollback', 3); @@ -178,12 +160,6 @@ xa_start xa_noflags 3; xa_getconnection; --- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; select * from global_xactTable order by gxid, status, username, type; drop table foo; create table foo (a int); Index: java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java =================================================================== --- java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java (revision 191099) +++ java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java (working copy) @@ -177,8 +177,6 @@ xid = getXid(27, (byte) 21, (byte) 01); xr.start(xid, XAResource.TMNOFLAGS); conn1 = xac.getConnection(); - System.out.println("This is a bug. Connection's holdability should have been CLOSE_CURSORS_AT_COMMIT since it is in the global transaction"); - System.out.println("Have reported this on Derby dev-list"); System.out.println("CONNECTION(in xa transaction) HOLDABILITY " + (conn1.getHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT)); System.out.println("Autocommit on Connection inside global transaction has been set correctly to " + conn1.getAutoCommit()); xr.end(xid, XAResource.TMSUCCESS); Index: java/testing/org/apache/derbyTesting/functionTests/master/xaOffline1.out =================================================================== --- java/testing/org/apache/derbyTesting/functionTests/master/xaOffline1.out (revision 191099) +++ java/testing/org/apache/derbyTesting/functionTests/master/xaOffline1.out (working copy) @@ -6,12 +6,6 @@ xa_connect ; ij> xa_start xa_noflags 0; ij> xa_getconnection; -ij(XA)> -- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; ij(XA)> drop table foo; ERROR 42Y55: 'DROP TABLE' cannot be performed on 'FOO' because it does not exist. ij(XA)> create table foo (a int); @@ -140,12 +134,6 @@ IJ ERROR: XAER_DUPID ij(XA)> xa_start xa_noflags 4; ij(XA)> xa_getconnection; -ij(XA)> -- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; ij(XA)> select * from global_xactTable where gxid is not null order by gxid; GXID|STATUS |READ&|USERNAME |TYPE ------------------------------------------------------------- Index: java/testing/org/apache/derbyTesting/functionTests/master/xaSimplePositive.out =================================================================== --- java/testing/org/apache/derbyTesting/functionTests/master/xaSimplePositive.out (revision 191099) +++ java/testing/org/apache/derbyTesting/functionTests/master/xaSimplePositive.out (working copy) @@ -5,12 +5,6 @@ xa_connect ; ij> xa_start xa_noflags 0; ij> xa_getconnection; -ij(XA)> -- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; ij(XA)> drop table foo; ERROR 42Y55: 'DROP TABLE' cannot be performed on 'FOO' because it does not exist. ij(XA)> create table foo (a int); @@ -46,12 +40,6 @@ ij(XA)> xa_connect user 'sku' password 'testxa' ; ij(XA)> xa_start xa_noflags 1; ij(XA)> xa_getconnection; -ij(XA)> -- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; ij(XA)> insert into APP.foo values (1); 1 row inserted/updated/deleted ij(XA)> xa_end xa_suspend 1; @@ -148,12 +136,6 @@ 3 ij(LOCAL)> xa_start xa_resume 4; ij(LOCAL)> xa_getconnection; -ij(XA)> -- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; ij(XA)> insert into APP.foo values (4); 1 row inserted/updated/deleted ij(XA)> disconnect; @@ -170,12 +152,6 @@ --disconnect; xa_start xa_resume 5; ij(LOCAL)> xa_getconnection; -ij(XA)> -- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; ij(XA)> insert into APP.foo values (5); 1 row inserted/updated/deleted ij(XA)> xa_end xa_success 5; Index: java/testing/org/apache/derbyTesting/functionTests/master/xab2354.out =================================================================== --- java/testing/org/apache/derbyTesting/functionTests/master/xab2354.out (revision 191099) +++ java/testing/org/apache/derbyTesting/functionTests/master/xab2354.out (working copy) @@ -2,12 +2,6 @@ ij> xa_connect; ij> xa_start xa_noflags 1; ij> xa_getconnection; -ij(XA)> -- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; ij(XA)> create table foo (a int); 0 rows inserted/updated/deleted ij(XA)> insert into foo values (1); Index: java/testing/org/apache/derbyTesting/functionTests/master/xaSimpleNegative.out =================================================================== --- java/testing/org/apache/derbyTesting/functionTests/master/xaSimpleNegative.out (revision 191099) +++ java/testing/org/apache/derbyTesting/functionTests/master/xaSimpleNegative.out (working copy) @@ -9,12 +9,6 @@ xa_start xa_noflags 1; IJ ERROR: XAER_PROTO ij> xa_getconnection; -ij(XA)> -- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; ij(XA)> -- ERROR: cannot get connection again xa_getconnection; ERROR XJ059: Cannot close a connection while a global transaction is still active. @@ -99,12 +93,6 @@ IJ ERROR: XA_RBROLLBACK ij> xa_start xa_noflags 2; ij> xa_getconnection; -ij(XA)> -- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; ij(XA)> insert into APP.negative values ('ok', 3); 1 row inserted/updated/deleted ij(XA)> -- ERROR: cannot suspend some other xid @@ -137,12 +125,6 @@ ij> -- this is OK xa_start xa_join 2; ij> xa_getconnection; -ij(XA)> -- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; ij(XA)> -- ERROR: another dup insert into APP.negative values ('rollback', 3); ERROR 23505: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'NEGATIVEI' defined on 'NEGATIVE'. @@ -196,12 +178,6 @@ ij(XA)> disconnect; ij> xa_start xa_noflags 3; ij> xa_getconnection; -ij(XA)> -- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; ij(XA)> select * from global_xactTable order by gxid, status, username, type; GXID|STATUS |READ&|USERNAME |TYPE ------------------------------------------------------------- Index: java/testing/org/apache/derbyTesting/functionTests/master/xaAnotherTest.out =================================================================== --- java/testing/org/apache/derbyTesting/functionTests/master/xaAnotherTest.out (revision 191099) +++ java/testing/org/apache/derbyTesting/functionTests/master/xaAnotherTest.out (working copy) @@ -6,12 +6,6 @@ xa_connect ; ij> xa_start xa_noflags 0; ij> xa_getconnection; -ij> -- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; ij> drop table APP.foo; ERROR 42Y55: 'DROP TABLE' cannot be performed on 'APP.FOO' because it does not exist. ij> create table APP.foo (a int); @@ -48,12 +42,6 @@ ij> -- global connection 1 xa_start xa_noflags 1; ij> xa_getconnection; -ij> -- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; ij> insert into APP.foo values (1); 1 row inserted/updated/deleted ij> xa_end xa_suspend 1; @@ -155,12 +143,6 @@ ij(LOCAL2)> -- add couple more global transactions xa_start xa_noflags 6; ij(LOCAL2)> xa_getconnection; -ij(XA)> -- Global transactions can not have hold cursor over commit. And hence we need to make sure the holdability is false for all jdks --- In jdk13 and lower, this Brokered Connection has its holdability false over commit so we are fine. --- In jdk14 and higher, this Brokered Connection has its holdability true over commit. In order to set it to false, we have NoHoldForConnection --- NoHoldForConnection uses setHoldability api on Connection to set the holdability to false. But this api exists only for jdk14 and higher --- And that is why, in jkd13 master, we see an exception nosuchmethod -NoHoldForConnection; ij(XA)> insert into APP.foo values (6); 1 row inserted/updated/deleted ij(XA)> xa_end xa_suspend 6; Index: java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out =================================================================== --- java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out (revision 191099) +++ java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out (working copy) @@ -225,7 +225,7 @@ EmbeddedXADataSource .execute() XJ012 - 'Statement' already closed. EVENT(5):connectionClosed Running JDBC 3.0 connection checks on Global EmbeddedXADataSource - holdability true + holdability false JDBC 3.0 savepoint SQL Exception: Cannot rollback a global transaction using the Connection, commit processing must go thru XAResource interface. Running connection checks on Global EmbeddedXADataSource isolation level 2 @@ -240,7 +240,7 @@ Global EmbeddedXADataSource .createStatement() 08003 - No current connection. Global EmbeddedXADataSource .execute() XJ012 - 'Statement' already closed. Running JDBC 3.0 connection checks on Global EmbeddedXADataSource - holdability true + holdability false JDBC 3.0 savepoint SQL Exception: Cannot rollback a global transaction using the Connection, commit processing must go thru XAResource interface. Running connection checks on Global EmbeddedXADataSource isolation level 2 @@ -303,7 +303,7 @@ Switch to global EmbeddedXADataSource .createStatement() 08003 - No current connection. Switch to global EmbeddedXADataSource .execute() XJ012 - 'Statement' already closed. Running JDBC 3.0 connection checks on Switch to global EmbeddedXADataSource - holdability true + holdability false JDBC 3.0 savepoint SQL Exception: Cannot rollback a global transaction using the Connection, commit processing must go thru XAResource interface. Running connection checks on Switch to global EmbeddedXADataSource isolation level 2 @@ -361,7 +361,7 @@ read only false EVENT(6):connectionClosed re-join with new handle X1 - holdability true + holdability false isolation level READ_UNCOMMITTED auto commit false read only true @@ -372,7 +372,7 @@ auto commit true read only false pre-X1 commit - X1 - holdability true + holdability false isolation level READ_UNCOMMITTED auto commit false read only true @@ -721,9 +721,7 @@ Notice that autocommit now is false for connection because it is part of the global transaction Notice that connection's holdability at this point is CLOSE_CURSORS_AT_COMMIT because it is part of the global transaction CONNECTION(in xa transaction) HOLDABILITY false -This is a bug. Connection's holdability should have been CLOSE_CURSORS_AT_COMMIT since it is in the global transaction -Have reported this on Derby dev-list -CONNECTION(in xa transaction) HOLDABILITY true +CONNECTION(in xa transaction) HOLDABILITY false Autocommit on Connection inside global transaction has been set correctly to false CONNECTION(non-xa) HOLDABILITY false STATEMENT HOLDABILITY false