-
Notifications
You must be signed in to change notification settings - Fork 42
Statement.getUpdateCount() throws SQLException after getResultSet() for SELECT statements #205
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
Comments
This change implements a group of `Large` methods, like `executeLargeUpdate`, that were added in Java 8 (JDBC 4.2). Testing: existing prepared statement tests are moved to a separate file and updated to cover all `Large` methods. Fixes: duckdb#205
Thanks for the report! I wonder if you are calling try (Connection conn = DriverManager.getConnection("jdbc:duckdb:");
Statement stmt = conn.createStatement()) {
stmt.execute("SELECT 42");
try (ResultSet rs = stmt.getResultSet()) {
System.out.println(stmt.getUpdateCount());
while (rs.next());
System.out.println(stmt.getUpdateCount());
}
} About |
Hi @staticlibs, thank you for the reply. While the statement should indeed be initialized beforehand, my point was about the potential state of the underlying statement at the moment @Override
public boolean getMoreResults() throws SQLException {
final boolean hasMore = stmt.getMoreResults(); // <-- this could be the trigger of the exception
queryResult.reset();
// getResultSet() succeed while a subsequent call to getUpdateCount() fails
queryResult.updateAll(null, hasMore ? new WrappedResultSet(this, stmt.getResultSet()) : null,
stmt.getUpdateCount());
return hasMore;
} There might be scenarios where the statement is no longer valid when attempting to retrieve the next result. |
This change implements a group of `Large` methods, like `executeLargeUpdate`, that were added in Java 8 (JDBC 4.2). Testing: existing prepared statement tests are moved to a separate file and updated to cover all `Large` methods. Fixes: duckdb#205
This change implements a group of `Large` methods, like `executeLargeUpdate`, that were added in Java 8 (JDBC 4.2). Testing: existing prepared statement tests are moved to a separate file and updated to cover all `Large` methods. Fixes: #205
I got the following exception when calling
Statement.getUpdateCount()
aftergetResultSet()
for SELECT statements:Could you please enhance the driver to align with the JDBC specification and return
-1
fromStatement.getUpdateCount()
(and similarlygetLargeUpdateCount
) when "the result is a ResultSet object or there are no more results"?The text was updated successfully, but these errors were encountered: