tursodatabase/turso · error · SQLException
SQLite only supports TYPE_FORWARD_ONLY cursors
Error message
SQLite only supports TYPE_FORWARD_ONLY cursors
What it means
checkCursor() enforces the only result-set type the engine supports: TYPE_FORWARD_ONLY (rows stream once, no scrolling). createStatement(type, ...) or prepareStatement(sql, type, ...) with any other type throws immediately before execution.
Solutions
- Use the no-arg createStatement()/prepareStatement(sql) or pass TYPE_FORWARD_ONLY explicitly
- For pagination, rewrite as SQL: LIMIT/OFFSET or keyset (WHERE id > ? ORDER BY id LIMIT n)
- If you truly need scrolling, materialize rows into a cache and navigate in memory
Example fix
// before Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); // after Statement st = conn.createStatement(); // defaults to forward-only, read-only
Defensive patterns
Strategy: validation
Validate before calling
// normalize before creating statements
int type = resultSetType == ResultSet.TYPE_FORWARD_ONLY ? resultSetType : ResultSet.TYPE_FORWARD_ONLY;
if (resultSetType != ResultSet.TYPE_FORWARD_ONLY) {
LOG.warn("scrollable result sets unsupported; downgraded to TYPE_FORWARD_ONLY");
}
Statement st = conn.createStatement(type, ResultSet.CONCUR_READ_ONLY); Try / catch
try {
return conn.createStatement(reqType, ResultSet.CONCUR_READ_ONLY);
} catch (SQLException e) {
if (e.getMessage().contains("TYPE_FORWARD_ONLY")) return conn.createStatement(); // retry with default
throw e;
} Prevention
- Default to the no-arg createStatement()/prepareStatement(sql) — it already uses the supported combination
- Configure ORMs/frameworks (e.g. Hibernate) to non-scrollable, LIMIT/OFFSET pagination
- Encapsulate statement creation in one helper so unsupported constants are caught in one place
When it happens
Trigger: Calling createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ...) or prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE, ...); frameworks requesting scrollable result sets (e.g. Hibernate scrollable results, some reporting tools).
Common situations: Porting an app from a JDBC driver that supports scrolling (MySQL/PostgreSQL); ORM pagination configured for scroll-insensitive cursors; IDE-generated JDBC boilerplate with non-default constants.
Related errors
- SQLite only supports closing cursors at commit
- SQLite only supports CONCUR_READ_ONLY cursors
- Cannot change isolation level while transaction is active.
- Cannot commit in autocommit mode.
- Cannot rollback in autocommit mode.
AI-assisted analysis of tursodatabase/turso@244cde92a7 (2026-08-20).
Data as JSON: /api/errors/c451af4dd2b06f5b.
Report an issue: GitHub.
Appendix: source
Thrown at bindings/java/src/main/java/tech/turso/core/TursoConnection.java:160
// TODO: check whether this is still valid for turso
/**
* Checks whether the type, concurrency, and holdability settings for a {@link ResultSet} are
* supported by the SQLite interface. Supported settings are:
*
* <ul>
* <li>type: {@link ResultSet#TYPE_FORWARD_ONLY}
* <li>concurrency: {@link ResultSet#CONCUR_READ_ONLY})
* <li>holdability: {@link ResultSet#CLOSE_CURSORS_AT_COMMIT}
* </ul>
*
* @param resultSetType the type setting.
* @param resultSetConcurrency the concurrency setting.
* @param resultSetHoldability the holdability setting.
*/
public void checkCursor(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
throws SQLException {
if (resultSetType != ResultSet.TYPE_FORWARD_ONLY) {
throw new SQLException("SQLite only supports TYPE_FORWARD_ONLY cursors");
}
if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) {
throw new SQLException("SQLite only supports CONCUR_READ_ONLY cursors");
}
if (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) {
throw new SQLException("SQLite only supports closing cursors at commit");
}
}
/**
* Sets the auto-commit mode for this connection.
*
* <p>When auto-commit is enabled (the default), each SQL statement is committed automatically
* upon completion. When auto-commit is disabled, statements are grouped into transactions that
* must be explicitly committed or rolled back.
*
* <p>If this method is called to enable auto-commit while a transaction is active, the current
* transaction is committed first.View on GitHub (pinned to 244cde92a7)