-
Notifications
You must be signed in to change notification settings - Fork 632
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
Call JDBC3PreparedStatement.executeQuery
can return null
#914
Comments
This is difficult to investigate as it apparently relies on a 3rd party project. Are you able to provide a repro that is not using CP2 ? |
Using only package com.example;
import java.sql.DriverManager;
public class App {
public static void main(String[] args) throws Exception {
try (var connection = DriverManager.getConnection("jdbc:sqlite:file:memDb?mode=memory&cache=shared")) {
try (var statement = connection.prepareStatement("SELECT 1")) {
var process = statement.execute();
while (process) {
var result = statement.getResultSet();
while (result.next()) {
System.out.printf("Step 1: value must be '1': %s\n", result.getString(1));
}
process = statement.getMoreResults();
}
var result = statement.executeQuery();
while (result.next()) {
System.out.printf("Step 2: value must be '1': %s\n", result.getString(1));
}
}
}
}
} In log:
|
I updated the example: |
Thanks, i can reproduce in a unit test. |
🎉 This issue has been resolved in |
gotson
added a commit
to gotson/sqlite-jdbc
that referenced
this issue
Oct 18, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I noticed an error after update
org.xerial:sqlite-jdbc
to latest version.Describe the bug
The call of
org.sqlite.jdbc3.JDBC3PreparedStatement.executeQuery
can returnnull
, which is against the specifications.This can happen when using
org.apache.commons.dbcp2.BasicDataSource
(fromorg.apache.commons:commons-dbcp2
) with enabled prepared statements pool:dataSource.setPoolPreparedStatements(true)
.As I understand it, the problem is in the
org.sqlite.jdbc3.JDBC3Statement.exhaustedResults
flag, which is enabled when the prepared statement is reused.To Reproduce
Example for reproducing:
pom.xml
src/main/java/com/example/App.java
Expected behavior
Show "OK" in output:
Logs
Execution will cause an error associated with the described bug (resultSet cannot be
null
by specs):Environment:
Additional context
Stacktrace before returning
null
(withorg.xerial:sqlite-jdbc:3.42.0.0
):The text was updated successfully, but these errors were encountered: