{"record":{"id":"f827a861b3a9ce17","repo":"apache/shardingsphere","slug":"updatebytes","errorCode":null,"errorMessage":"updateBytes","messagePattern":"updateBytes","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java","lineNumber":154,"sourceCode":"    \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\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","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java#L136-L172","documentation":"AbstractUnsupportedUpdateOperationSQLFederationResultSet supplies the update contract for all ShardingSphere federation ResultSets: every updateXxx method throws SQLFeatureNotSupportedException, with 'updateBytes' as the message for the binary updater (column-index overload). Federated rows are computed in memory and read-only, so in-place binary column writes through the cursor fail fast by design.","triggerScenarios":"Calling ResultSet.updateBytes(int columnIndex, byte[] x) on a ResultSet from a federated statement (sql_federation enabled, e.g. cross-shard join over BLOB-like VARBINARY columns). Encountered in media/blob handling code or generic serializers that patch binary columns via the cursor.","commonSituations":"Blob/attachment code ported from driver-native updatable cursors to ShardingSphere federation; batch jobs that rewrite encoded binary flags in place; enabling sqlFederation so existing statements now return federation result sets with these final unsupported overrides.","solutions":["Read with getBytes(columnIndex) and write via a PreparedStatement UPDATE using setBytes, keyed on the primary key.","Check rs.getConcurrency() before any update-cursor branch and fall back to statement-based writes for read-only sets.","Exclude the statement from sql_federation so the underlying driver's ResultSet (and its own concurrency support) is used."],"exampleFix":"// before\nrs.updateBytes(2, newBytes);  // SQLFeatureNotSupportedException: updateBytes\nrs.updateRow();\n\n// after\ntry (PreparedStatement upd = conn.prepareStatement(\"UPDATE assets SET payload = ? WHERE id = ?\")) {\n    upd.setBytes(1, newBytes);\n    upd.setLong(2, rs.getLong(1));\n    upd.executeUpdate();\n}","handlingStrategy":"try-catch","validationCode":"if (rs.getConcurrency() != ResultSet.CONCUR_UPDATABLE) {\n    // rs.updateBytes(...) unsupported; use UPDATE + setBytes\n}","typeGuard":"private static boolean supportsRowUpdates(final ResultSet rs) throws SQLException {\n    return rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE;\n}","tryCatchPattern":"try {\n    rs.updateBytes(2, payload);\n} catch (final SQLFeatureNotSupportedException ignored) {\n    try (PreparedStatement upd = conn.prepareStatement(\"UPDATE assets SET payload = ? WHERE id = ?\")) {\n        upd.setBytes(1, payload);\n        upd.setLong(2, rs.getLong(1));\n        upd.executeUpdate();\n    }\n}","preventionTips":["Write binary columns via setBytes on keyed UPDATE statements.","Check result-set concurrency before blob-patch logic.","Avoid selecting large binary columns in federated queries; fetch them by key on routed queries."],"tags":["jdbc","resultset","sql-federation","read-only","shardingsphere","binary"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}