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 dj...@apache.org on 2006/04/04 20:41:39 UTC
svn commit: r391383 - in /db/derby/code/trunk/java:
build/org/apache/derbyBuild/ client/org/apache/derby/client/am/
engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/loc/
shared/org/apache/derby/shared/common/reference/ testing/org/apache/derb...
Author: djd
Date: Tue Apr 4 11:41:36 2006
New Revision: 391383
URL: http://svn.apache.org/viewcvs?rev=391383&view=rev
Log:
DERBY-1158 (partial) Implement downgrading a request to create any holdable statement in a global
transaction to return a non-holdable statement. Such a downgrade adds a SQLWarning to the Connection
object. This follows section 16.1.3.1 from JDBC 4.0 proposed final draft.
Modified:
db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java
db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.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/master/XATest.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.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/checkDataSource30.java
Modified: db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java?rev=391383&r1=391382&r2=391383&view=diff
==============================================================================
--- db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java (original)
+++ db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java Tue Apr 4 11:41:36 2006
@@ -64,6 +64,7 @@
clientMessageIds.add(SQLState.LANG_STATEMENT_CLOSED_NO_REASON);
clientMessageIds.add(SQLState.LANG_INVALID_COLUMN_POSITION);
clientMessageIds.add(SQLState.INVALID_COLUMN_NAME);
+ clientMessageIds.add(SQLState.HOLDABLE_RESULT_SET_NOT_AVAILABLE);
}
public static void main(String[] args) throws Exception {
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=391383&r1=391382&r2=391383&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 Tue Apr 4 11:41:36 2006
@@ -1469,11 +1469,19 @@
// In an XA global transaction do not allow the
// holdability to be set to hold cursors across
// commits, as the engine does not support it.
+ // Downgrade the holdability to CLOSE_CURSORS_AT_COMMIT
+ // and attach a warning. This is specified in
+ // JDBC 4.0 (proposed final draft) section 16.1.3.1
+ // Similar code is not needed for PreparedStatement
+ // as the holdability gets pushed all the way to the
+ // engine and handled there.
if (this.isXAConnection_ && this.xaState_ == XA_T1_ASSOCIATED)
{
- if (resultSetHoldability == JDBC30Translation.HOLD_CURSORS_OVER_COMMIT)
- throw new SqlException(agent_.logWriter_,
- new MessageId(SQLState.CANNOT_HOLD_CURSOR_XA));
+ if (resultSetHoldability == JDBC30Translation.HOLD_CURSORS_OVER_COMMIT) {
+ resultSetHoldability = JDBC30Translation.CLOSE_CURSORS_AT_COMMIT;
+ accumulateWarning(new SqlWarning(agent_.logWriter_,
+ new MessageId(SQLState.HOLDABLE_RESULT_SET_NOT_AVAILABLE)));
+ }
}
Statement s = newStatement_(resultSetType, resultSetConcurrency, resultSetHoldability);
s.cursorAttributesToSendOnPrepare_ = s.cacheCursorAttributesToSendOnPrepare();
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java?rev=391383&r1=391382&r2=391383&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java Tue Apr 4 11:41:36 2006
@@ -28,6 +28,7 @@
import java.sql.SQLException;
import java.sql.SQLWarning;
+import org.apache.derby.impl.jdbc.EmbedSQLWarning;
import org.apache.derby.impl.jdbc.Util;
import java.io.ObjectOutput;
@@ -496,6 +497,15 @@
{
return getRealConnection().getPrepareIsolation();
}
+
+ /**
+ * Add a SQLWarning to this Connection object.
+ * @throws SQLException
+ */
+ public final void addWarning(SQLWarning w) throws SQLException
+ {
+ getRealConnection().addWarning(w);
+ }
/**
* Get the string representation for this connection. Return
@@ -582,8 +592,12 @@
throws SQLException
{
int holdability = control.checkHoldCursors(resultSetHoldability, true);
- if (holdability != resultSetHoldability)
- throw Util.generateCsSQLException(SQLState.CANNOT_HOLD_CURSOR_XA);
+ if (holdability != resultSetHoldability) {
+ SQLWarning w =
+ EmbedSQLWarning.newEmbedSQLWarning(SQLState.HOLDABLE_RESULT_SET_NOT_AVAILABLE);
+
+ addWarning(w);
+ }
return holdability;
Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java?rev=391383&r1=391382&r2=391383&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java Tue Apr 4 11:41:36 2006
@@ -22,6 +22,7 @@
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
+import java.sql.SQLWarning;
import org.apache.derby.iapi.reference.SQLState;
import org.apache.derby.iapi.sql.execute.ExecutionContext;
@@ -82,5 +83,13 @@
* Can be removed once JDK 1.3 is no longer supported.
*/
public int getHoldability() throws SQLException;
+
+ /**
+ * Add a SQLWarning to this Connection object.
+ * @param newWarning Warning to be added, will be chained to any
+ * existing warnings.
+ */
+ public void addWarning(SQLWarning newWarning)
+ throws SQLException;
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties?rev=391383&r1=391382&r2=391383&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties Tue Apr 4 11:41:36 2006
@@ -1159,6 +1159,7 @@
01J04=The class ''{0}'' for column ''{1}'' does not implement java.io.Serializable or java.sql.SQLData. Instances must implement one of these interfaces to allow them to be stored.
01J05=Database upgrade succeeded. The upgraded database is now ready for use. Revalidating stored prepared statements failed. See next exception for details of failure.
01J06=ResultSet not updatable. Query does not qualify to generate an updatable ResultSet.
+01J07=ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT for a global transaction.
XJ001.U=Java exception: ''{1}: {0}''.
XJ050.U=Database requires upgrade from version {0}, set the attribute ''upgrade=true'' on the JDBC connection URL to allow upgrade to version {1}.
Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java?rev=391383&r1=391382&r2=391383&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java (original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java Tue Apr 4 11:41:36 2006
@@ -1517,6 +1517,7 @@
String LANG_TYPE_NOT_SERIALIZABLE = "01J04";
String UPGRADE_SPSRECOMPILEFAILED = "01J05";
String QUERY_NOT_QUALIFIED_FOR_UPDATABLE_RESULTSET = "01J06";
+ String HOLDABLE_RESULT_SET_NOT_AVAILABLE = "01J07";
String CURSOR_OPERATION_CONFLICT = "01001";
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out?rev=391383&r1=391382&r2=391383&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 Tue Apr 4 11:41:36 2006
@@ -41,7 +41,7 @@
GXID |STATUS |READONLY |USERNAME |TYPE
-----
(1 |IDLE |NULL |APP |UserTransaction
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
+OK: query with holdable statement
Statement created in global has holdabilty: false
A
-----
@@ -189,10 +189,9 @@
EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
+Global createStatement(hold)Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+01J07 :java.sql.SQLWarning: ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT for a global transaction.
+Global prepareStatement(hold)Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+01J07 :java.sql.SQLWarning: ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT for a global transaction.
derby966 complete
XATest complete
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out?rev=391383&r1=391382&r2=391383&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out Tue Apr 4 11:41:36 2006
@@ -41,7 +41,6 @@
GXID|STATUS |READONLY|USERNAME |TYPE
----------------------------------------------------------------
(1 |IDLE |NULL |APP |UserTransaction
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
Statement created in global has holdabilty: false
A
-----------
@@ -174,10 +173,10 @@
EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
-EXPECTED SQLSTATE(XJ05C): Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
+Global createStatement(hold)Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+01J07 :SQL Warning: ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT for a global transaction.
+Global prepareStatement(hold)Statement holdable CLOSE_CURSORS_AT_COMMIT 2
+01J07 :SQL Warning: ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT for a global transaction.
+01J07 :SQL Warning: ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT for a global transaction.
derby966 complete
XATest complete
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out?rev=391383&r1=391382&r2=391383&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out Tue Apr 4 11:41:36 2006
@@ -860,9 +860,9 @@
CONNECTION(held) HOLDABILITY true
CONNECTION(xa) HOLDABILITY false
Expected SQLException(setHoldability) Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
-Expected SQLException (Statement hold) Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
-Expected SQLException (PreparedStatement hold) Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
-Expected SQLException (CallableStatement hold) Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
+HOLDABLE Statement in global xact false connection warning ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT for a global transaction.
+HOLDABLE PreparedStatement in global xact false connection warning ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT for a global transaction.
+HOLDABLE CallableStatement in global xact false connection warning ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT for a global transaction.
STATEMENT HOLDABILITY true
Expected SQLException (local Statement hold) Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
Expected SQLException (local Statement hold) Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a global transaction.
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java?rev=391383&r1=391382&r2=391383&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 Tue Apr 4 11:41:36 2006
@@ -24,6 +24,7 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.Properties;
@@ -549,15 +550,15 @@
conn.setAutoCommit(false);
// s was created in local mode so it has holdibilty
- // set,
- try {
- s.executeQuery("select * from APP.foo where A >= 2000");
- System.out.println("FAIL: query with holdable statement");
- } catch (SQLException sqle) {
- TestUtil.dumpSQLExceptions(sqle, true);
+ // set, will execute but ResultSet will have close on commit
+
+ if (TestUtil.isDerbyNetClientFramework()) { // DERBY-1158
+ s.executeQuery("select * from APP.foo where A >= 2000").close();
+ System.out.println("OK: query with holdable statement");
}
s.close();
-
+
+
s = conn.createStatement();
boolean holdable = s.getResultSetHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT;
System.out.println("Statement created in global has holdabilty: "
@@ -916,18 +917,11 @@
xar.start(xid, XAResource.TMNOFLAGS);
// Statements obtained while default was hold.
- // Only sch should work as held cursors not supported in XA
- try {
- sdh.executeQuery("SELECT * FROM APP.FOO").close();
- System.out.println("FAIL - held Statement in global");
- } catch (SQLException e) {
- TestUtil.dumpSQLExceptions(e, true);
- }
- try {
- shh.executeQuery("SELECT * FROM APP.FOO").close();
- System.out.println("FAIL - held Statement in global");
- } catch (SQLException e) {
- TestUtil.dumpSQLExceptions(e, true);
+ // All should work, holability will be downgraded
+ // to close on commit for those Statements with hold set.
+ if (TestUtil.isDerbyNetClientFramework()) { // DERBY-1158
+ sdh.executeQuery("SELECT * FROM APP.FOO").close();
+ shh.executeQuery("SELECT * FROM APP.FOO").close();
}
sch.executeQuery("SELECT * FROM APP.FOO").close();
@@ -943,13 +937,13 @@
// Only sch should work as held cursors not supported in XA
try {
psdh.executeQuery().close();
- System.out.println("FAIL - held Statement in global");
+ System.out.println("FAIL - held Statement in global psdf");
} catch (SQLException e) {
TestUtil.dumpSQLExceptions(e, true);
}
try {
pshh.executeQuery().close();
- System.out.println("FAIL - held Statement in global");
+ System.out.println("FAIL - held Statement in global pshh");
} catch (SQLException e) {
TestUtil.dumpSQLExceptions(e, true);
}
@@ -965,11 +959,8 @@
// Statements obtained while default was close.
// Only sch should work as held cursors not supported in XA
sdc.executeQuery("SELECT * FROM APP.FOO").close();
- try {
- shc.executeQuery("SELECT * FROM APP.FOO").close();
- System.out.println("FAIL - held Statement in global");
- } catch (SQLException e) {
- TestUtil.dumpSQLExceptions(e, true);
+ if (TestUtil.isDerbyNetClientFramework()) { // DERBY-1158
+ shc.executeQuery("SELECT * FROM APP.FOO").close();
}
scc.executeQuery("SELECT * FROM APP.FOO").close();
@@ -999,7 +990,6 @@
// Test we cannot switch the connection to holdable
- // or create a statement with holdable.
try {
conn.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);
System.out.println("FAIL - set holdability in global xact.");
@@ -1008,25 +998,25 @@
TestUtil.dumpSQLExceptions(sqle, true);
}
- try {
- conn.createStatement(
+ // JDBC 4.0 (proposed final draft) section allows
+ // drivers to change the holdability when creating
+ // a Statement object and attach a warning to the Connection.
+ Statement sglobalhold = conn.createStatement(
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY,
ResultSet.HOLD_CURSORS_OVER_COMMIT);
- System.out.println("FAIL - Statement holdability in global xact.");
- } catch (SQLException sqle) {
- TestUtil.dumpSQLExceptions(sqle, true);
- }
- try {
- conn.prepareStatement(
+ showHoldStatus("Global createStatement(hold)", sglobalhold);
+ sglobalhold.close();
+
+ PreparedStatement psglobalhold = conn.prepareStatement(
"SELECT * FROM APP.FOO",
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY,
ResultSet.HOLD_CURSORS_OVER_COMMIT);
- System.out.println("FAIL - PreparedStatement holdability in global xact.");
- } catch (SQLException sqle) {
- TestUtil.dumpSQLExceptions(sqle, true);
- }
+ showHoldStatus("Global prepareStatement(hold)", psglobalhold);
+ psglobalhold.close();
+
+
xar.end(xid, XAResource.TMSUCCESS);
if (xar.prepare(xid) != XAResource.XA_RDONLY)
System.out.println("FAIL prepare didn't indicate r/o");
@@ -1108,6 +1098,13 @@
{
System.out.println(tag + "Statement holdable " +
holdStatus(s.getResultSetHoldability()));
+ SQLWarning w = s.getConnection().getWarnings();
+ while (w != null)
+ {
+ System.out.println(w.getSQLState() + " :" + w.toString());
+ w = w.getNextWarning();
+ }
+
}
/**
* Show the held status of the Connection.
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java?rev=391383&r1=391382&r2=391383&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java Tue Apr 4 11:41:36 2006
@@ -331,27 +331,34 @@
System.out.println("Expected SQLException(setHoldability) " + sqle.getMessage());
}
- try {
- Statement shxa = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
- System.out.println("FAIL opened statement with hold cursor attribute in global transaction");
- } catch (SQLException sqle) {
- System.out.println("Expected SQLException (Statement hold) " + sqle.getMessage());
- }
- try {
- Statement shxa = conn.prepareStatement("select id from hold_30",
+ // JDBC 4.0 (proposed final draft) section 16.1.3.1 allows Statements to
+ // be created with a different holdability if the driver cannot support it.
+ // In this case the driver does not support holdability in a global transaction
+ // so a valid statement is returned with close cursors on commit,
+
+ Statement shxa = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,
+ ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
+ System.out.println("HOLDABLE Statement in global xact " +
+ (s.getResultSetHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT) +
+ " connection warning " + conn.getWarnings().getMessage());
+ shxa.close();
+
+
+ shxa = conn.prepareStatement("select id from hold_30",
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
- System.out.println("FAIL opened statement with hold cursor attribute in global transaction");
- } catch (SQLException sqle) {
- System.out.println("Expected SQLException (PreparedStatement hold) " + sqle.getMessage());
- }
- try {
- Statement shxa = conn.prepareCall("CALL XXX.TTT()",
+ System.out.println("HOLDABLE PreparedStatement in global xact " +
+ (s.getResultSetHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT) +
+ " connection warning " + conn.getWarnings().getMessage());
+ shxa.close();
+
+ shxa = conn.prepareCall("CALL SYSCS_UTIL.SYSCS_CHECKPOINT_DATABASE()",
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
- System.out.println("FAIL opened statement with hold cursor attribute in global transaction");
- } catch (SQLException sqle) {
- System.out.println("Expected SQLException (CallableStatement hold) " + sqle.getMessage());
- }
-
+ System.out.println("HOLDABLE CallableStatement in global xact " +
+ (s.getResultSetHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT) +
+ " connection warning " + conn.getWarnings().getMessage());
+ shxa.close();
+
+
// check we cannot use a holdable statement set up in local mode.
System.out.println("STATEMENT HOLDABILITY " + (sh.getResultSetHoldability() == ResultSet.HOLD_CURSORS_OVER_COMMIT));
try {