{"record":{"id":"9808ec2e32f753ad","repo":"apache/shardingsphere","slug":"updatestring","errorCode":null,"errorMessage":"updateString","messagePattern":"updateString","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java","lineNumber":134,"sourceCode":"    \n    @Override\n    public final void updateDouble(final String columnLabel, final double x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateDouble\");\n    }\n    \n    @Override\n    public final void updateBigDecimal(final int columnIndex, final BigDecimal x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateBigDecimal\");\n    }\n    \n    @Override\n    public final void updateBigDecimal(final String columnLabel, final BigDecimal x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateBigDecimal\");\n    }\n    \n    @Override\n    public final void updateString(final int columnIndex, final String x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateString\");\n    }\n    \n    @Override\n    public final void updateString(final String columnLabel, final String x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateString\");\n    }\n    \n    @Override\n    public final void updateNString(final int columnIndex, final String nString) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateNString\");\n    }\n    \n    @Override\n    public final void updateNString(final String columnLabel, final String nString) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateNString\");\n    }\n    \n    @Override","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java#L116-L152","documentation":"In ShardingSphere, every ResultSet produced by the SQL federation engine extends AbstractUnsupportedUpdateOperationSQLFederationResultSet, whose updateXxx overrides are final and throw SQLFeatureNotSupportedException with the method name ('updateString') as the message. Federation results are read-only computed views, so updating a String column in place via the cursor is always rejected.","triggerScenarios":"Calling ResultSet.updateString(int columnIndex, String x) while iterating a federation ResultSet (query executed by SQL federation, e.g. cross-shard JOIN with sql_federation enabled). Triggered by row editors, admin consoles, or ORM dirty-flush logic that writes back through the cursor.","commonSituations":"Admin/CRUD screens written against updatable ResultSets later pointed at a ShardingSphere federated datasource; enabling sqlFederation globally and having formerly simple queries federated; generic table-model code that patches cells via updateString.","solutions":["Use getString(columnIndex) to read and write changes with a PreparedStatement UPDATE keyed on the primary key.","Before cursor-update code, verify rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE; otherwise use statement-based updates.","Configure the sql_federation rule so this statement is not federated (scope by SQL pattern/table) and the native ResultSet is returned."],"exampleFix":"// before\nrs.updateString(2, \"new-name\");  // SQLFeatureNotSupportedException: updateString\nrs.updateRow();\n\n// after\ntry (PreparedStatement upd = conn.prepareStatement(\"UPDATE users SET name = ? WHERE id = ?\")) {\n    upd.setString(1, \"new-name\");\n    upd.setLong(2, rs.getLong(1));\n    upd.executeUpdate();\n}","handlingStrategy":"try-catch","validationCode":"if (rs.getConcurrency() != ResultSet.CONCUR_UPDATABLE) {\n    // rs.updateString(...) is unsupported; use UPDATE statements\n}","typeGuard":"private static boolean supportsRowUpdates(final ResultSet rs) throws SQLException {\n    return rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE;\n}","tryCatchPattern":"try {\n    rs.updateString(2, name);\n} catch (final SQLFeatureNotSupportedException ignored) {\n    try (PreparedStatement upd = conn.prepareStatement(\"UPDATE users SET name = ? WHERE id = ?\")) {\n        upd.setString(1, name);\n        upd.setLong(2, rs.getLong(1));\n        upd.executeUpdate();\n    }\n}","preventionTips":["Design row editing as read-then-UPDATE, not cursor mutation.","Assert result-set concurrency in shared table-model utilities before updateXxx.","Keep admin/edit screens off federated queries or accept their read-only nature."],"tags":["jdbc","resultset","sql-federation","read-only","shardingsphere"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}