Connection conn1 = xac.getConnection();
System.out.println("By default, autocommit is " + conn1.getAutoCommit() + " for a connection");
System.out.println("Default holdability for a connection is HOLD_CURSORS_OVER_COMMIT");
System.out.println("CONNECTION(not in xa transaction yet) HOLDABILITY " + (conn1.getHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT));
//start a global transaction and default holdability and autocommit will be switched to match Derby XA restrictions
xr.start(xid, XAResource.TMNOFLAGS);
System.out.println("Notice that autocommit now is " + conn1.getAutoCommit() + " for connection because it is part of the global transaction");
System.out.println("Notice that connection's holdability at this point is CLOSE_CURSORS_AT_COMMIT because it is part of the global transaction");
System.out.println("CONNECTION(in xa transaction) HOLDABILITY " + (conn1.getHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT));
xr.end(xid, XAResource.TMSUCCESS);
conn1.commit();