{"record":{"id":"515821b17d6c7244","repo":"tursodatabase/turso","slug":"sqlite-only-supports-concur-read-only-cursors","errorCode":null,"errorMessage":"SQLite only supports CONCUR_READ_ONLY cursors","messagePattern":"SQLite only supports CONCUR_READ_ONLY cursors","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"bindings/java/src/main/java/tech/turso/core/TursoConnection.java","lineNumber":163,"sourceCode":"   * supported by the SQLite interface. Supported settings are:\n   *\n   * <ul>\n   *   <li>type: {@link ResultSet#TYPE_FORWARD_ONLY}\n   *   <li>concurrency: {@link ResultSet#CONCUR_READ_ONLY})\n   *   <li>holdability: {@link ResultSet#CLOSE_CURSORS_AT_COMMIT}\n   * </ul>\n   *\n   * @param resultSetType the type setting.\n   * @param resultSetConcurrency the concurrency setting.\n   * @param resultSetHoldability the holdability setting.\n   */\n  public void checkCursor(int resultSetType, int resultSetConcurrency, int resultSetHoldability)\n      throws SQLException {\n    if (resultSetType != ResultSet.TYPE_FORWARD_ONLY) {\n      throw new SQLException(\"SQLite only supports TYPE_FORWARD_ONLY cursors\");\n    }\n    if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) {\n      throw new SQLException(\"SQLite only supports CONCUR_READ_ONLY cursors\");\n    }\n    if (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) {\n      throw new SQLException(\"SQLite only supports closing cursors at commit\");\n    }\n  }\n\n  /**\n   * Sets the auto-commit mode for this connection.\n   *\n   * <p>When auto-commit is enabled (the default), each SQL statement is committed automatically\n   * upon completion. When auto-commit is disabled, statements are grouped into transactions that\n   * must be explicitly committed or rolled back.\n   *\n   * <p>If this method is called to enable auto-commit while a transaction is active, the current\n   * transaction is committed first.\n   *\n   * @param autoCommit true to enable auto-commit mode; false to disable it\n   * @throws SQLException if a database access error occurs or the connection is closed","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/java/src/main/java/tech/turso/core/TursoConnection.java#L145-L181","documentation":"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.","triggerScenarios":"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.","commonSituations":"Code ported from drivers where updatable cursors worked; tools that call rs.updateString()/updateRow(); boilerplate copied with CONCUR_UPDATABLE constants.","solutions":["Pass CONCUR_READ_ONLY (or use the no-arg createStatement/prepareStatement)","Replace rs.updateX()/rs.updateRow() with a prepared UPDATE statement","Configure the framework/tool to read-only mode for this connection"],"exampleFix":"// before\nStatement st = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);\nrs.updateString(1, \"v\"); rs.updateRow();\n\n// after\nStatement st = conn.createStatement();\nconn.prepareStatement(\"UPDATE t SET col = ? WHERE id = ?\")","handlingStrategy":"validation","validationCode":"if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) {\n  throw new IllegalArgumentException(\"updatable result sets are not supported; use UPDATE statements\");\n}\nStatement st = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);","typeGuard":null,"tryCatchPattern":"try {\n  return conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, concurrency);\n} catch (SQLException e) {\n  if (e.getMessage().contains(\"CONCUR_READ_ONLY\")) return conn.createStatement();\n  throw e;\n}","preventionTips":["Never use CONCUR_UPDATABLE with this driver — plan writes as explicit UPDATE/INSERT statements","Replace rs.updateRow() patterns with PreparedStatement updates keyed by primary key","Centralize statement creation to keep the read-only constraint enforced everywhere"],"tags":["jdbc","resultset","java"],"backgroundTag":"unsupported-resultset-type","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}