1 21 22 package org.apache.derbyTesting.functionTests.tests.jdbcapi; 23 24 import junit.framework.*; 25 26 import org.apache.derbyTesting.junit.BaseJDBCTestCase; 27 28 import java.sql.*; 29 30 45 public class ResultSetCloseTest extends BaseJDBCTestCase { 46 47 48 52 public void setUp() 53 throws SQLException { 54 Connection con = getConnection(); 55 con.setAutoCommit(false); 56 57 Statement s = con.createStatement(); 58 59 s.execute("create table t1 (a int)"); 60 61 s.execute("insert into t1 values(1)"); 62 s.execute("insert into t1 values(0)"); 63 s.execute("insert into t1 values(2)"); 64 s.execute("insert into t1 values(3)"); 65 66 s.close(); 67 68 con.commit(); 69 } 70 71 84 public void testResultSetDoesNotClose() throws SQLException { 85 86 PreparedStatement ps1 = prepareStatement("select * from t1"); 87 PreparedStatement ps2 = prepareStatement("select 10/a from t1"); 88 89 ResultSet rs1 = ps1.executeQuery(); 90 91 try { 92 ResultSet rs2 = ps2.executeQuery(); 93 while(rs2.next()); 94 } catch(SQLException sqle) { 95 } 97 98 while(rs1.next()); 99 100 commit(); 101 102 rs1.close(); 103 ps1.close(); 104 ps2.close(); 105 } 106 107 112 public ResultSetCloseTest(String name) { 113 super(name); 114 } 115 116 119 public static Test suite() { 120 121 TestSuite suite = new TestSuite("ResultSetCloseTest"); 122 123 if (usingDerbyNet()) 127 return suite; 128 129 suite.addTestSuite(ResultSetCloseTest.class); 130 return suite; 131 } 132 133 } 134 | Popular Tags |