{"record":{"id":"2e5cc447a031c0ed","repo":"apache/shardingsphere","slug":"updatelong","errorCode":null,"errorMessage":"updateLong","messagePattern":"updateLong","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java","lineNumber":94,"sourceCode":"    \n    @Override\n    public final void updateShort(final String columnLabel, final short x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateShort\");\n    }\n    \n    @Override\n    public final void updateInt(final int columnIndex, final int x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateInt\");\n    }\n    \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","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java#L76-L112","documentation":"ShardingSphere's SQL federation query engine returns a read-only ResultSet. AbstractUnsupportedUpdateOperationSQLFederationResultSet implements every JDBC row-update method (updateInt, updateLong, ...) as 'throw new SQLFeatureNotSupportedException(...)', and the concrete federation result sets inherit these final overrides. The message 'updateLong' names the JDBC method that was rejected. The class exists so that programs which try to modify rows through a federated query fail fast and explicitly instead of silently doing nothing.","triggerScenarios":"Calling ResultSet.updateLong(int columnIndex, long x) on a ResultSet produced by a SQL federation query (sql_federation enabled, e.g. cross-shard JOIN / subquery / federated SELECT). This happens when application code is handed a generic ResultSet and is written against an updatable cursor contract, or when an ORM row-mapping layer attempts to write back to the current row.","commonSituations":"Upgrading from a direct JDBC driver or a non-federated ShardingSphere query (where updateLong may have worked on an updatable cursor) to a federated query; generic data-access utility code that calls updateXxx on any ResultSet it receives; enabling sql_federation for cross-database queries and reusing existing updatable-resultset code paths.","solutions":["Stop using ResultSet.updateLong on federation results: read values with getLong and write changes through a separate UPDATE statement (PreparedStatement.executeUpdate).","If you do not need federation for this statement, disable SQL federation for it (rule sql_federation scope / sqlFederationEnabled=false) so the driver-backed ResultSet is returned with its native concurrency.","Guard the call site: check rs.getConcurrency() == ResultSet.CONCUR_READ_ONLY (or DatabaseMetaData.supportsResultSetConcurrency) before entering any updateXxx code path, and route read-only result sets to the UPDATE-statement strategy.","Wrap the federation query path in a component that only exposes read operations, so update-capable code never receives a federation ResultSet."],"exampleFix":"// before\nResultSet rs = federatedStmt.executeQuery(sql);\nrs.next();\nrs.updateLong(1, 42L);   // SQLFeatureNotSupportedException: updateLong\nrs.updateRow();\n\n// after\nResultSet rs = federatedStmt.executeQuery(sql);\nrs.next();\nlong id = rs.getLong(1);\ntry (PreparedStatement upd = conn.prepareStatement(\"UPDATE t SET v = ? WHERE id = ?\")) {\n    upd.setLong(1, 42L);\n    upd.setLong(2, id);\n    upd.executeUpdate();\n}","handlingStrategy":"try-catch","validationCode":"if (rs.getConcurrency() != ResultSet.CONCUR_UPDATABLE) {\n    // read-only federation ResultSet: use UPDATE statements instead of updateXxx\n}","typeGuard":"private static boolean isReadOnlyFederationResultSet(final ResultSet rs) throws SQLException {\n    return rs.getConcurrency() == ResultSet.CONCUR_READ_ONLY\n            && rs.getClass().getName().startsWith(\"org.apache.shardingsphere.sqlfederation\");\n}","tryCatchPattern":"try {\n    rs.updateLong(1, value);\n} catch (final SQLFeatureNotSupportedException ignored) {\n    // federation ResultSet is read-only: fall back to a keyed UPDATE statement\n    try (PreparedStatement upd = conn.prepareStatement(\"UPDATE t SET v = ? WHERE id = ?\")) {\n        upd.setLong(1, value);\n        upd.setLong(2, rs.getLong(1));\n        upd.executeUpdate();\n    }\n}","preventionTips":["Treat every sql_federation result set as read-only; design write paths around UPDATE statements from the start.","Check rs.getConcurrency() before entering any updateRow-based code path.","Keep federation queries behind read-only repository methods so update-capable layers never receive them."],"tags":["jdbc","resultset","sql-federation","read-only","shardingsphere"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}