db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r392333 - in /db/derby/code/branches/10.1/java: client/org/apache/derby/client/am/ engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/iapi/reference/ engine/org/apache/derby/loc/ testing/org/apache/derbyTesting/functionTests/master/...
Date Fri, 07 Apr 2006 16:47:41 GMT
Author: djd
Date: Fri Apr  7 09:47:39 2006
New Revision: 392333

URL: http://svn.apache.org/viewcvs?rev=392333&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.
Merge of 391383 from trunk

Modified:
    db/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java
    db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
    db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java
    db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/reference/SQLState.java
    db/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java

Modified: db/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java?rev=392333&r1=392332&r2=392333&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java (original)
+++ db/derby/code/branches/10.1/java/client/org/apache/derby/client/am/Connection.java Fri
Apr  7 09:47:39 2006
@@ -1237,12 +1237,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 == ClientDataSource.HOLD_CURSORS_OVER_COMMIT)
-                throw new SqlException(agent_.logWriter_, 
-                        "Cannot set holdability ResultSet.HOLD_CURSORS_OVER_COMMIT for a
global transaction.",
-                        "XJ05C");
+            if (resultSetHoldability == ClientDataSource.HOLD_CURSORS_OVER_COMMIT) {
+                resultSetHoldability = ClientDataSource.CLOSE_CURSORS_AT_COMMIT;
+                accumulateWarning(new SqlWarning(agent_.logWriter_, 
+                        "ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT
for a global transaction.", "01J07"));
+            }
         }
         Statement s = newStatement_(resultSetType, resultSetConcurrency, resultSetHoldability);
         s.cursorAttributesToSendOnPrepare_ = s.cacheCursorAttributesToSendOnPrepare();

Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java?rev=392333&r1=392332&r2=392333&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
(original)
+++ db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection.java
Fri Apr  7 09:47:39 2006
@@ -28,7 +28,7 @@
 import java.sql.SQLException;
 import java.sql.SQLWarning;
 
-import org.apache.derby.client.am.SqlState;
+import org.apache.derby.impl.jdbc.EmbedSQLWarning;
 import org.apache.derby.impl.jdbc.Util;
 
 import java.io.ObjectOutput;
@@ -496,6 +496,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 the underlying physical
@@ -585,8 +594,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/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java?rev=392333&r1=392332&r2=392333&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java
(original)
+++ db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/jdbc/EngineConnection.java
Fri Apr  7 09:47:39 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/branches/10.1/java/engine/org/apache/derby/iapi/reference/SQLState.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/reference/SQLState.java?rev=392333&r1=392332&r2=392333&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/reference/SQLState.java
(original)
+++ db/derby/code/branches/10.1/java/engine/org/apache/derby/iapi/reference/SQLState.java
Fri Apr  7 09:47:39 2006
@@ -1439,6 +1439,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";
 
 
     //following are database severity

Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties?rev=392333&r1=392332&r2=392333&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties (original)
+++ db/derby/code/branches/10.1/java/engine/org/apache/derby/loc/messages_en.properties Fri
Apr  7 09:47:39 2006
@@ -1122,6 +1122,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/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out?rev=392333&r1=392332&r2=392333&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/XATest.out
Fri Apr  7 09:47:39 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 :org.apache.derby.client.am.SqlWarning: ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT
for a global transaction.
+Global prepareStatement(hold)Statement holdable HOLD_CURSORS_OVER_COMMIT 1
+01J07 :org.apache.derby.client.am.SqlWarning: ResultSetHoldability restricted to ResultSet.CLOSE_CURSORS_AT_COMMIT
for a global transaction.
 derby966 complete
 XATest complete

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out?rev=392333&r1=392332&r2=392333&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/XATest.out
Fri Apr  7 09:47:39 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/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out?rev=392333&r1=392332&r2=392333&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/checkDataSource30.out
Fri Apr  7 09:47:39 2006
@@ -840,9 +840,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/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java?rev=392333&r1=392332&r2=392333&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XATest.java
Fri Apr  7 09:47:39 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;
 
@@ -545,15 +546,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: "
@@ -890,18 +891,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();
             
@@ -909,13 +903,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);
             }
@@ -924,11 +918,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();
             
@@ -943,7 +934,6 @@
             pscc.executeQuery().close();
                    
             // 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.");
@@ -952,25 +942,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");
@@ -1052,6 +1042,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/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java?rev=392333&r1=392332&r2=392333&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource30.java
Fri Apr  7 09:47:39 2006
@@ -300,27 +300,34 @@
 			}
 
 			// try to create a statement with held attributes
-			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 {



Mime
View raw message