{"record":{"id":"951654f8c5c28f87","repo":"apache/shardingsphere","slug":"updaterow","errorCode":null,"errorMessage":"updateRow","messagePattern":"updateRow","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java","lineNumber":100,"sourceCode":"    \n    @Override\n    public final boolean relative(final int rows) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"relative\");\n    }\n    \n    @Override\n    public final int getRow() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getRow\");\n    }\n    \n    @Override\n    public final void insertRow() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"insertRow\");\n    }\n    \n    @Override\n    public final void updateRow() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateRow\");\n    }\n    \n    @Override\n    public final void deleteRow() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"deleteRow\");\n    }\n    \n    @Override\n    public final void refreshRow() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"refreshRow\");\n    }\n    \n    @Override\n    public final void cancelRowUpdates() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"cancelRowUpdates\");\n    }\n    \n    @Override","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java#L82-L118","documentation":"ShardingSphere's sharding ResultSet (ShardingSphereResultSet extends AbstractUnsupportedOperationResultSet) permanently disables row-updatable ResultSet operations. updateRow() always throws SQLFeatureNotSupportedException because the driver merges rows from multiple physical ResultSets across shards and cannot map a modified merged row back to exactly one underlying cursor for a positioned UPDATE.","triggerScenarios":"Calling ResultSet.updateRow() on a ResultSet obtained from org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource — typically after updateXxx(...) calls, or via ORM/framework code (e.g. Hibernate updatable result sets, JDBI, Spring's ColumnMapRowMapper flows) that assumes CONCUR_UPDATABLE semantics.","commonSituations":"Porting an existing JDBC application that uses updatable ResultSets to a sharding datasource; ORMs or reporting tools configured for scrollable/updatable cursors; copy-paste of client-server DB code (Oracle/DB2 positioned updates) onto MySQL shards.","solutions":["Replace the positioned update with an explicit SQL UPDATE executed through PreparedStatement (e.g. UPDATE t SET col=? WHERE pk=?) so it routes normally.","If updateRow is issued by a framework, disable updatable-result-set features in that framework (request ResultSet.CONCUR_READ_ONLY when creating the Statement).","For a single-table, non-sharded path, obtain a plain Connection from the underlying physical datasource and perform the positioned update there."],"exampleFix":"// before\nrs.updateString(2, \"newVal\");\nrs.updateRow(); // SQLFeatureNotSupportedException under ShardingSphere\n\n// after\ntry (PreparedStatement ps = conn.prepareStatement(\"UPDATE t SET col = ? WHERE id = ?\")) {\n    ps.setString(1, \"newVal\");\n    ps.setLong(2, id);\n    ps.executeUpdate();\n}","handlingStrategy":"try-catch","validationCode":"// before any positioned update, confirm the cursor is updatable\nif (rs.getConcurrency() == ResultSet.CONCUR_READ_ONLY) {\n    // ShardingSphere always reports read-only: use SQL UPDATE instead\n}","typeGuard":"boolean supportsRowUpdate(ResultSet rs) throws SQLException {\n    return rs.getConcurrency() != ResultSet.CONCUR_READ_ONLY;\n}","tryCatchPattern":"try {\n    rs.updateRow();\n} catch (SQLFeatureNotSupportedException e) {\n    // fall back to keyed UPDATE SQL\n    LOGGER.warn(\"driver does not support positioned updates; using SQL UPDATE\", e);\n    executeKeyedUpdate(id, newValues);\n}","preventionTips":["Create Statements with ResultSet.CONCUR_READ_ONLY so frameworks never attempt positioned updates.","Route all modifications through PreparedStatement DML with explicit WHERE keys.","Audit migrated code for updateRow/deleteRow/insertRow before switching the JDBC URL to ShardingSphere."],"tags":["jdbc","resultset","row-updates","shardingsphere","unsupported-operation"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}