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

NullPointerException on Calling getMoreResults #593

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

NullPointerException on Calling getMoreResults #593

dwenking opened this issue Nov 16, 2023 · 0 comments

Comments

@dwenking
Copy link

The bug manifests as an unexpected NullPointerException when invoking the getMoreResults method. In the provided test case, after executing a batch insert into a table and retrieving the generated keys using getGeneratedKeys(), the method getMoreResults(Statement.KEEP_CURRENT_RESULT) is called on the Statement object. This call unexpectedly results in a NullPointerException. The stack trace indicates that the exception is due to an attempt to invoke isEmpty() on a null object (this.resultBatches).

@Test
public void test() throws SQLException {
    Connection con;
    Statement stmt;
    ResultSet rs ;
    con = DriverManager.getConnection("jdbc:pgsql://localhost:5432/test5?user=user&password=password");
    stmt = con.createStatement();
    stmt.execute("CREATE TABLE table5_0(id FLOAT PRIMARY KEY,value VARCHAR(100));");
    stmt.addBatch("INSERT INTO table5_0 VALUES(1, 'SeXM.j;.xbN5tXkzPPY')");
    stmt.executeBatch();
    rs = stmt.getGeneratedKeys();
    stmt.getMoreResults(Statement.KEEP_CURRENT_RESULT); // java.lang.NullPointerException: Cannot invoke "java.util.List.isEmpty()" because "this.resultBatches" is null
    rs.close();
    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