Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execution of executeUpdate Closes Previously Acquired ResultSet #592

Open
dwenking opened this issue Nov 16, 2023 · 0 comments
Open

Execution of executeUpdate Closes Previously Acquired ResultSet #592

dwenking opened this issue Nov 16, 2023 · 0 comments

Comments

@dwenking
Copy link

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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant