tursodatabase/turso · error · SQLException
The result set is not open
Error message
The result set is not open
What it means
TursoResultSet.consumeAll() requires the set to be open. open becomes false when close() is called, when a previous next() hit an invalid step state (next() sets open = false before throwing), or when the owning statement was closed/reset (reset() replaces the ResultSet entirely).
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 bad083fafb)
Solutions
- Check rs.isOpen() before calling consumeAll()
- Treat any earlier SQLException from next() as terminal — the set is already closed and must not be drained
- Re-execute the statement if you need a fresh, open ResultSet
Example fix
// before
rs.close();
rs.consumeAll(); // throws: The result set is not open
// after
if (rs.isOpen()) {
rs.consumeAll();
} Defensive patterns
Strategy: validation
Validate before calling
if (rs.isOpen()) {
rs.consumeAll();
} Try / catch
try {
rs.consumeAll();
} catch (SQLException e) {
if ("The result set is not open".equals(e.getMessage())) {
// already drained or closed — nothing to do
} else {
throw e;
}
} Prevention
- Only call consumeAll() immediately after execution, before any close()
- Treat any SQLException from next() as having closed the set — never drain afterwards
- After stmt.reset(), use the new getResultSet(), not the old reference
When it happens
Trigger: Calling consumeAll() after rs.close(), after a SQLException from next() already closed the set, or on the statement's result set after TursoStatement.reset() created a fresh one.
Common situations: Cleanup code that drains unread result sets in finally blocks after an earlier error; re-running a statement and draining the stale pre-reset ResultSet; interleaved usage of two result sets from one statement.
Related errors
- ResultSet closed
- ResultSet is not open
- SQLite only supports TYPE_FORWARD_ONLY cursors
- SQLite only supports CONCUR_READ_ONLY cursors
- SQLite only supports closing cursors at commit
AI-assisted analysis of tursodatabase/turso@bad083fafb (2026-08-16).
Data as JSON: /api/errors/a1bea34f4e465daf.
Report an issue: GitHub.