The execution of an executeUpdate statement unexpectedly leads to the closure of a previously obtained ResultSet object.
In the provided test case, a ResultSet object is obtained by calling getGeneratedKeys() on a Statement object after executing an UPDATE statement. This ResultSet is expected to remain open for subsequent operations. However, when another executeUpdate is executed on the same Statement object, the previously obtained ResultSet is found to be closed.
The expected behavior is that executing an executeUpdate statement should not affect the state (open or closed) of a previously acquired ResultSet.
@Test
public void test() throws SQLException {
Connection con;
Statement stmt;
ResultSet rs;
con = DriverManager.getConnection("jdbc:pgsql://localhost:5432/test16?user=user&password=password");
stmt = con.createStatement(1003, 1008, 2);
stmt.executeUpdate("CREATE TABLE table16_0(id REAL PRIMARY KEY,value BIT);");
stmt.executeUpdate("UPDATE table16_0 SET value = 77::bit WHERE id <= 1", 1);
stmt.executeBatch();
rs = stmt.getGeneratedKeys();
System.out.println(rs.isClosed()); // false
stmt.executeUpdate("UPDATE table16_0 SET value = 77::bit WHERE id <= 1", 1);
System.out.println(rs.isClosed()); // true
con.close();
}
The execution of an executeUpdate statement unexpectedly leads to the closure of a previously obtained ResultSet object. In the provided test case, a ResultSet object is obtained by calling getGeneratedKeys() on a Statement object after executing an UPDATE statement. This ResultSet is expected to remain open for subsequent operations. However, when another executeUpdate is executed on the same Statement object, the previously obtained ResultSet is found to be closed. The expected behavior is that executing an executeUpdate statement should not affect the state (open or closed) of a previously acquired ResultSet.