apache/shardingsphere · error · SQLFeatureNotSupportedException
updateBytes
Error message
updateBytes
What it means
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.
Source
Thrown at kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java:154
@Override
public final void updateString(final String columnLabel, final String x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateString");
}
@Override
public final void updateNString(final int columnIndex, final String nString) throws SQLException {
throw new SQLFeatureNotSupportedException("updateNString");
}
@Override
public final void updateNString(final String columnLabel, final String nString) throws SQLException {
throw new SQLFeatureNotSupportedException("updateNString");
}
@Override
public final void updateBytes(final int columnIndex, final byte[] x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateBytes");
}
@Override
public final void updateBytes(final String columnLabel, final byte[] x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateBytes");
}
@Override
public final void updateDate(final int columnIndex, final Date x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateDate");
}
@Override
public final void updateDate(final String columnLabel, final Date x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateDate");
}
@OverrideView on GitHub (pinned to e952770a21)
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.
Example fix
// before
rs.updateBytes(2, newBytes); // SQLFeatureNotSupportedException: updateBytes
rs.updateRow();
// after
try (PreparedStatement upd = conn.prepareStatement("UPDATE assets SET payload = ? WHERE id = ?")) {
upd.setBytes(1, newBytes);
upd.setLong(2, rs.getLong(1));
upd.executeUpdate();
} Defensive patterns
Strategy: try-catch
Validate before calling
if (rs.getConcurrency() != ResultSet.CONCUR_UPDATABLE) {
// rs.updateBytes(...) unsupported; use UPDATE + setBytes
} Type guard
private static boolean supportsRowUpdates(final ResultSet rs) throws SQLException {
return rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE;
} Try / catch
try {
rs.updateBytes(2, payload);
} catch (final SQLFeatureNotSupportedException ignored) {
try (PreparedStatement upd = conn.prepareStatement("UPDATE assets SET payload = ? WHERE id = ?")) {
upd.setBytes(1, payload);
upd.setLong(2, rs.getLong(1));
upd.executeUpdate();
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/f827a861b3a9ce17.
Report an issue: GitHub.