{"record":{"id":"dd45c5a50a2270ff","repo":"apache/shardingsphere","slug":"updatedate","errorCode":null,"errorMessage":"updateDate","messagePattern":"updateDate","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java","lineNumber":164,"sourceCode":"    \n    @Override\n    public final void updateNString(final String columnLabel, final String nString) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateNString\");\n    }\n    \n    @Override\n    public final void updateBytes(final int columnIndex, final byte[] x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateBytes\");\n    }\n    \n    @Override\n    public final void updateBytes(final String columnLabel, final byte[] x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateBytes\");\n    }\n    \n    @Override\n    public final void updateDate(final int columnIndex, final Date x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateDate\");\n    }\n    \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","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java#L146-L182","documentation":"Every updateXxx method on a ShardingSphere SQL federation ResultSet is a final override in AbstractUnsupportedUpdateOperationSQLFederationResultSet that throws SQLFeatureNotSupportedException with the method name as the message — 'updateDate' for the column-index overload. Federation output is a read-only computed view, so writing a java.sql.Date in place through the cursor is unsupported and fails immediately.","triggerScenarios":"Calling ResultSet.updateDate(int columnIndex, Date x) on a federation ResultSet (statement executed by the SQL federation engine, e.g. cross-shard join with sql_federation enabled). Seen in scheduling/calendar code or generic date-column editors that patch rows in place.","commonSituations":"Applications that previously used updatable driver ResultSets for date patches and now run federated queries; sqlFederation enabled during sharding adoption, routing existing statements through federation; reusable row-editing layers that call updateDate on any ResultSet they receive.","solutions":["Read with getDate(columnIndex) and persist via a PreparedStatement UPDATE using setDate, keyed on the primary key.","Pre-check rs.getConcurrency(); treat read-only sets as statement-update-only and never call updateRow flows.","Scope the sql_federation rule to exclude this statement so the backend driver's ResultSet is returned."],"exampleFix":"// before\nrs.updateDate(3, Date.valueOf(\"2026-08-14\"));  // SQLFeatureNotSupportedException: updateDate\nrs.updateRow();\n\n// after\ntry (PreparedStatement upd = conn.prepareStatement(\"UPDATE events SET due_date = ? WHERE id = ?\")) {\n    upd.setDate(1, Date.valueOf(\"2026-08-14\"));\n    upd.setLong(2, rs.getLong(1));\n    upd.executeUpdate();\n}","handlingStrategy":"try-catch","validationCode":"if (rs.getConcurrency() != ResultSet.CONCUR_UPDATABLE) {\n    // rs.updateDate(...) unsupported; use UPDATE + setDate\n}","typeGuard":"private static boolean supportsRowUpdates(final ResultSet rs) throws SQLException {\n    return rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE;\n}","tryCatchPattern":"try {\n    rs.updateDate(3, date);\n} catch (final SQLFeatureNotSupportedException ignored) {\n    try (PreparedStatement upd = conn.prepareStatement(\"UPDATE events SET due_date = ? WHERE id = ?\")) {\n        upd.setDate(1, date);\n        upd.setLong(2, rs.getLong(1));\n        upd.executeUpdate();\n    }\n}","preventionTips":["Write date columns via setDate on keyed UPDATE statements.","Check rs.getConcurrency() before calendar/scheduling row edits.","Keep editable date grids on non-federated queries."],"tags":["jdbc","resultset","sql-federation","read-only","shardingsphere","date"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}