db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r673327 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementPoolingTest.java
Date Wed, 02 Jul 2008 09:15:34 GMT
Author: kristwaa
Date: Wed Jul  2 02:15:34 2008
New Revision: 673327

URL: http://svn.apache.org/viewvc?rev=673327&view=rev
Log:
DERBY-3446: Make ResultSet.getStatement return the correct statement when created by a logical
statement.
Added regression test for the bug in JDBC statement caching environments.
Patch file: derby-3446-3a-stmtpool_test.diff

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementPoolingTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementPoolingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementPoolingTest.java?rev=673327&r1=673326&r2=673327&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementPoolingTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementPoolingTest.java
Wed Jul  2 02:15:34 2008
@@ -597,6 +597,51 @@
     }
 
     /**
+     * Make sure {@link ResultSet#getStatement} returns the same object as the
+     * one that created the result set.
+     */
+    public void testGetStatementCallable()
+            throws SQLException {
+        doTestGetStatement(prepareCall("values 7653"));
+    }
+
+    /**
+     * Make sure {@link ResultSet#getStatement} returns the same object as the
+     * one that created the result set.
+     */
+    public void testGetStatementPrepared()
+            throws SQLException {
+        doTestGetStatement(prepareStatement("values 7652"));
+    }
+
+    /**
+     * Make sure {@link ResultSet#getStatement} returns the same object as the
+     * one that created the result set.
+     *
+     * @param ps prepared or callable statement to test with
+     * @throws SQLException if something goes wrong...
+     */
+    private void doTestGetStatement(PreparedStatement ps)
+            throws SQLException {
+        ResultSet psRs = ps.executeQuery();
+        assertSame(ps, psRs.getStatement());
+        psRs.close();
+        // Try another way.
+        ps.execute();
+        psRs = ps.getResultSet();
+        assertSame(ps, psRs.getStatement());
+        assertFalse(ps.getMoreResults());
+        assertNull(ps.getResultSet());
+        // This one should fail.
+        try {
+            psRs = ps.executeQuery("values 99");
+            fail("executeQuery(String) should be disallowed");
+        } catch (SQLException sqle) {
+            assertSQLState("XJ016", sqle);
+        }
+    }
+
+    /**
      * Checks if closing the logical connection closes the logical statement.
      *
      * @throws SQLException if something goes wrong...



Mime
View raw message