tursodatabase/turso · warning · SQLException
The result set is not open
Error message
The result set is not open
What it means
consumeAll() drains the ResultSet by looping next() until it returns false, and first requires the open flag to be true. The flag is set to false by close(), and next() itself auto-closes the set when the native step returns an invalid state. So this throw means you are draining a set that is already finished, explicitly closed, or errored out.
Solutions
- Guard the call: if (rs.isOpen()) rs.consumeAll();
- Consume exactly once per result set, typically right after execute when only the row count or statement completion matters
- If a prior step failed, re-run the query on a fresh statement rather than reusing the closed set
Example fix
// before
rs.consumeAll(); // throws when already closed
rs.close();
// after
if (rs.isOpen()) {
rs.consumeAll();
}
rs.close(); Defensive patterns
Strategy: validation
Validate before calling
if (rs.isOpen()) {
rs.consumeAll();
}
rs.close(); Try / catch
try {
rs.consumeAll();
} catch (SQLException e) {
// set already closed or errored: nothing left to drain; continue cleanup
} Prevention
- Drain exactly once, immediately after execute, when only completion or the row count matters
- Let one component own close(); all others only read isOpen()
- Centralize cleanup in one place instead of scattering consumeAll() calls
When it happens
Trigger: Calling consumeAll() after close(); calling it a second time on the same ResultSet; calling it after an earlier next() hit an invalid step result, which already set open=false.
Common situations: Cleanup code that drains-then-closes while another layer (try-with-resources, a helper) also closes; retry loops that reuse a result set instead of re-executing.
Related errors
- ResultSet closed
- ResultSet is not open
- The resultSet is not open
- column name not found
- columnIndex out of bound
AI-assisted analysis of tursodatabase/turso@244cde92a7 (2026-08-20).
Data as JSON: /api/errors/a1bea34f4e465daf.
Report an issue: GitHub.
Appendix: source
Thrown at bindings/java/src/main/java/tech/turso/core/TursoResultSet.java:53
public static TursoResultSet of(TursoStatement statement) {
return new TursoResultSet(statement);
}
private TursoResultSet(TursoStatement statement) {
this.open = true;
this.statement = statement;
}
/**
* Consumes all the rows in this {@link ResultSet} until the {@link #next()} method returns
* `false`.
*
* @throws SQLException if the result set is not open or if an error occurs while iterating.
*/
public void consumeAll() throws SQLException {
if (!open) {
throw new SQLException("The result set is not open");
}
while (next()) {}
}
/**
* Moves the cursor forward one row from its current position. A {@link TursoResultSet} cursor is
* initially positioned before the first fow; the first call to the method <code>next</code> makes
* the first row the current row; the second call makes the second row the current row, and so on.
* When a call to the <code>next</code> method returns <code>false</code>, the cursor is
* positioned after the last row.
*
* <p>Note that turso only supports <code>ResultSet.TYPE_FORWARD_ONLY</code>, which means that the
* cursor can only move forward.
*
* @return true if the new current row is valid; false if there are no more rows
* @throws SQLException if a database access error occurs
*/View on GitHub (pinned to 244cde92a7)