{"record":{"id":"7e24e163edc7b2d2","repo":"apache/shardingsphere","slug":"updatefloat","errorCode":null,"errorMessage":"updateFloat","messagePattern":"updateFloat","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java","lineNumber":104,"sourceCode":"    \n    @Override\n    public final void updateInt(final String columnLabel, final int x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateInt\");\n    }\n    \n    @Override\n    public final void updateLong(final int columnIndex, final long x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateLong\");\n    }\n    \n    @Override\n    public final void updateLong(final String columnLabel, final long x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateLong\");\n    }\n    \n    @Override\n    public final void updateFloat(final int columnIndex, final float x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateFloat\");\n    }\n    \n    @Override\n    public final void updateFloat(final String columnLabel, final float x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateFloat\");\n    }\n    \n    @Override\n    public final void updateDouble(final int columnIndex, final double x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateDouble\");\n    }\n    \n    @Override\n    public final void updateDouble(final String columnLabel, final double x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateDouble\");\n    }\n    \n    @Override","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java#L86-L122","documentation":"SQL federation result sets in ShardingSphere are read-only by construction: AbstractUnsupportedUpdateOperationSQLFederationResultSet overrides every JDBC row-update method to throw SQLFeatureNotSupportedException, and these overrides are final so subclasses cannot enable them. The message 'updateFloat' identifies the rejected method. Federated queries are materialized by the federation engine, so there is no backing updatable cursor to write through.","triggerScenarios":"Calling ResultSet.updateFloat(int columnIndex, float x) on the ResultSet of a federation-executed query (sql_federation applies, e.g. cross-shard join, UNION, or federated subquery). Triggered by row-editing utilities, grid components, or ORMs that use updatable-cursor APIs.","commonSituations":"Reusing GUI/reporting/grid code that edits rows via updateXxx against a ShardingSphere datasource with sql_federation turned on; migrating an application from raw MySQL/PostgreSQL updatable ResultSets to ShardingSphere federation; version upgrades where a statement newly qualifies for federation execution.","solutions":["Use getFloat(columnIndex) to read and issue an explicit UPDATE statement for writes; never call updateFloat on a federation ResultSet.","Check rs.getConcurrency() (or DatabaseMetaData.supportsResultSetConcurrency) before entering update-cursor code and fall back to UPDATE statements for CONCUR_READ_ONLY sets.","Narrow the sql_federation rule so this particular statement is not federated, letting the underlying driver return its native (possibly updatable) ResultSet."],"exampleFix":"// before\nrs.next();\nrs.updateFloat(2, 1.5f);  // SQLFeatureNotSupportedException: updateFloat\nrs.updateRow();\n\n// after\nfloat current = rs.getFloat(2);\ntry (PreparedStatement upd = conn.prepareStatement(\"UPDATE metrics SET score = ? WHERE id = ?\")) {\n    upd.setFloat(1, 1.5f);\n    upd.setLong(2, rs.getLong(1));\n    upd.executeUpdate();\n}","handlingStrategy":"try-catch","validationCode":"boolean updatable = rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE;\nif (!updatable) {\n    // use UPDATE statements instead of rs.updateFloat(...)\n}","typeGuard":"private static boolean supportsRowUpdates(final ResultSet rs) throws SQLException {\n    return rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE;\n}","tryCatchPattern":"try {\n    rs.updateFloat(2, score);\n} catch (final SQLFeatureNotSupportedException ignored) {\n    try (PreparedStatement upd = conn.prepareStatement(\"UPDATE metrics SET score = ? WHERE id = ?\")) {\n        upd.setFloat(1, score);\n        upd.setLong(2, rs.getLong(1));\n        upd.executeUpdate();\n    }\n}","preventionTips":["Route all writes through PreparedStatement/Statement APIs, never the ResultSet cursor, when federation may be active.","Verify DatabaseMetaData.supportsResultSetConcurrency before adopting updatable-cursor code.","Document which queries are federated so teams know those ResultSets are read-only."],"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"}