{"record":{"id":"a3eef306cf75cae5","repo":"apache/shardingsphere","slug":"updatetimestamp","errorCode":null,"errorMessage":"updateTimestamp","messagePattern":"updateTimestamp","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java","lineNumber":184,"sourceCode":"    \n    @Override\n    public final void updateDate(final String columnLabel, final Date x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateDate\");\n    }\n    \n    @Override\n    public final void updateTime(final int columnIndex, final Time x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateTime\");\n    }\n    \n    @Override\n    public final void updateTime(final String columnLabel, final Time x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateTime\");\n    }\n    \n    @Override\n    public final void updateTimestamp(final int columnIndex, final Timestamp x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateTimestamp\");\n    }\n    \n    @Override\n    public final void updateTimestamp(final String columnLabel, final Timestamp x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateTimestamp\");\n    }\n    \n    @Override\n    public final void updateAsciiStream(final int columnIndex, final InputStream inputStream) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateAsciiStream\");\n    }\n    \n    @Override\n    public final void updateAsciiStream(final String columnLabel, final InputStream inputStream) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateAsciiStream\");\n    }\n    \n    @Override","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java#L166-L202","documentation":"AbstractUnsupportedUpdateOperationSQLFederationResultSet defines all row-update methods of ShardingSphere's federation ResultSet as unconditional SQLFeatureNotSupportedException throws; 'updateTimestamp' is the message for the column-index overload. Because the federation engine computes results in memory and offers no writable cursor, in-place java.sql.Timestamp writes through the ResultSet always throw at the call site.","triggerScenarios":"Calling ResultSet.updateTimestamp(int columnIndex, Timestamp x) on a federated query ResultSet (sql_federation enabled, e.g. cross-shard join/subquery). Triggered by audit/last-modified stamping code or generic temporal writers that patch the current row in place.","commonSituations":"Optimistic-locking / audit-stamp code using updateRow migrated onto a ShardingSphere federated datasource; sqlFederation enabled in YAML causing existing statements to federate; framework code that updates timestamps through the cursor on every ResultSet.","solutions":["Read with getTimestamp(columnIndex) if needed and write via a PreparedStatement UPDATE using setTimestamp, keyed on the primary key.","Pre-validate rs.getConcurrency() and confine updateXxx usage to CONCUR_UPDATABLE result sets; otherwise use UPDATE statements.","Exclude the statement from the sql_federation rule so the underlying driver's ResultSet semantics are used."],"exampleFix":"// before\nrs.updateTimestamp(6, Timestamp.from(Instant.now()));  // SQLFeatureNotSupportedException: updateTimestamp\nrs.updateRow();\n\n// after\ntry (PreparedStatement upd = conn.prepareStatement(\"UPDATE docs SET modified_at = ? WHERE id = ?\")) {\n    upd.setTimestamp(1, Timestamp.from(Instant.now()));\n    upd.setLong(2, rs.getLong(1));\n    upd.executeUpdate();\n}","handlingStrategy":"try-catch","validationCode":"if (rs.getConcurrency() != ResultSet.CONCUR_UPDATABLE) {\n    // rs.updateTimestamp(...) unsupported; use UPDATE + setTimestamp\n}","typeGuard":"private static boolean supportsRowUpdates(final ResultSet rs) throws SQLException {\n    return rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE;\n}","tryCatchPattern":"try {\n    rs.updateTimestamp(6, ts);\n} catch (final SQLFeatureNotSupportedException ignored) {\n    try (PreparedStatement upd = conn.prepareStatement(\"UPDATE docs SET modified_at = ? WHERE id = ?\")) {\n        upd.setTimestamp(1, ts);\n        upd.setLong(2, rs.getLong(1));\n        upd.executeUpdate();\n    }\n}","preventionTips":["Stamp audit timestamps in keyed UPDATE statements, not via the ResultSet cursor.","Check rs.getConcurrency() before audit-stamp logic that receives arbitrary ResultSets.","Keep last-modified writes on the same connection/transaction as the read."],"tags":["jdbc","resultset","sql-federation","read-only","shardingsphere","timestamp"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}