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 kr...@apache.org on 2008/07/02 11:15:34 UTC
svn commit: r673327 -
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementPoolingTest.java
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...