db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r388093 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/jdbc/EmbedResultSet.java engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestResultSetMethods.java
Date Thu, 23 Mar 2006 07:58:54 GMT
Author: kahatlen
Date: Wed Mar 22 23:58:53 2006
New Revision: 388093

URL: http://svn.apache.org/viewcvs?rev=388093&view=rev
Log:
DERBY-1095 (partial): Closing an embedded connection does not seem to
close associated EmbedStatements

This patch makes EmbedResultSet.isClosed() return the correct result
when the connection is closed.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestResultSetMethods.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java?rev=388093&r1=388092&r2=388093&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java Wed Mar
22 23:58:53 2006
@@ -4274,5 +4274,30 @@
     	
     	streamUsedFlags[columnIndex - 1] = true;
     }
+
+    /**
+     * JDBC 4.0
+     *
+     * <p>
+     * Checks whether this <code>ResultSet</code> object has been
+     * closed, either automatically or because <code>close()</code>
+     * has been called.
+     *
+     * @return <code>true</code> if the <code>ResultSet</code> is
+     * closed, <code>false</code> otherwise
+     * @exception SQLException if a database error occurs
+     */
+    public final boolean isClosed() throws SQLException {
+        if (isClosed) return true;
+        try {
+            // isClosed is not updated when EmbedConnection.close() is
+            // called, so we need to check the status of the
+            // connection
+            checkExecIfClosed("");
+            return false;
+        } catch (SQLException sqle) {
+            return isClosed;
+        }
+    }
 }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java?rev=388093&r1=388092&r2=388093&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet40.java Wed Mar
22 23:58:53 2006
@@ -83,19 +83,6 @@
         return statement.getResultSetHoldability();
     }
     
-    /**
-     * Checks whether this <code>ResultSet</code> object has been
-     * closed, either automatically or because <code>close()</code>
-     * has been called.
-     *
-     * @return <code>true</code> if the <code>ResultSet</code> is
-     * closed, <code>false</code> otherwise
-     * @exception SQLException if a database error occurs
-     */
-    public final boolean isClosed() throws SQLException {
-        return isClosed;
-    }
-    
     public void updateNString(int columnIndex, String nString) throws SQLException {
         throw Util.notImplemented();
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestResultSetMethods.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestResultSetMethods.java?rev=388093&r1=388092&r2=388093&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestResultSetMethods.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestResultSetMethods.java
Wed Mar 22 23:58:53 2006
@@ -214,6 +214,18 @@
             assert_(count == 3, "expected three result sets");
             stmt.execute("drop procedure retrieve_result_sets");
 
+            // close statement
+            rs = stmt2.executeQuery("values(1)");
+            stmt2.close();
+            assert_(rs.isClosed(), "rs should be closed");
+
+            // close connection
+            Connection conn2 = ij.startJBMS();
+            stmt2 = conn2.createStatement();
+            rs = stmt2.executeQuery("values(1)");
+            conn2.close();
+            assert_(rs.isClosed(), "rs should be closed");
+
             stmt.close();
             stmt2.close();
             



Mime
View raw message