tursodatabase/turso · error · SQLException

SQLite only supports CONCUR_READ_ONLY cursors

Error message

SQLite only supports CONCUR_READ_ONLY cursors

What it means

checkCursor() rejects any concurrency mode except CONCUR_READ_ONLY: the engine cannot serve updatable cursors, so requesting CONCUR_UPDATABLE fails before the statement runs. Updates must go through separate INSERT/UPDATE/DELETE statements.

Solutions

  1. Pass CONCUR_READ_ONLY (or use the no-arg createStatement/prepareStatement)
  2. Replace rs.updateX()/rs.updateRow() with a prepared UPDATE statement
  3. Configure the framework/tool to read-only mode for this connection

Example fix

// before
Statement st = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
rs.updateString(1, "v"); rs.updateRow();

// after
Statement st = conn.createStatement();
conn.prepareStatement("UPDATE t SET col = ? WHERE id = ?")
Defensive patterns

Strategy: validation

Validate before calling

if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) {
  throw new IllegalArgumentException("updatable result sets are not supported; use UPDATE statements");
}
Statement st = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);

Try / catch

try {
  return conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, concurrency);
} catch (SQLException e) {
  if (e.getMessage().contains("CONCUR_READ_ONLY")) return conn.createStatement();
  throw e;
}

Prevention

When it happens

Trigger: Calling createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE) or the prepareStatement overload with CONCUR_UPDATABLE; frameworks or generated code defaulting to updatable result sets.

Common situations: Code ported from drivers where updatable cursors worked; tools that call rs.updateString()/updateRow(); boilerplate copied with CONCUR_UPDATABLE constants.

Related errors


AI-assisted analysis of tursodatabase/turso@244cde92a7 (2026-08-20). Data as JSON: /api/errors/515821b17d6c7244. Report an issue: GitHub.

Appendix: source

Thrown at bindings/java/src/main/java/tech/turso/core/TursoConnection.java:163

   * 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.
   *
   * @param autoCommit true to enable auto-commit mode; false to disable it
   * @throws SQLException if a database access error occurs or the connection is closed

View on GitHub (pinned to 244cde92a7)