apache/shardingsphere · error · SQLFeatureNotSupportedException

updateByte

Error message

updateByte

What it means

updateByte(int, byte) is another member of the JDBC in-place row-update API that the ShardingSphere federation ResultSet intentionally omits. The final method unconditionally throws SQLFeatureNotSupportedException since federated result rows cannot be written back.

Solutions

  1. Replace with an UPDATE statement binding the byte value to a PreparedStatement parameter.
  2. Check getConcurrency() before attempting any updateXXX call; treat CONCUR_READ_ONLY as 'use SQL updates'.
  3. Move such editing flows to a non-federated datasource or disable federation for those statements.
  4. Encapsulate all writes in one data-access layer so unsupported client-side updates cannot appear.

Example fix

// before
resultSet.updateByte(4, (byte) 9);
resultSet.updateRow();

// after
// UPDATE item SET qty = ? WHERE id = ?
Defensive patterns

Strategy: validation

Validate before calling

if (resultSet.getConcurrency() != ResultSet.CONCUR_UPDATABLE) { /* issue UPDATE with parameter binding */ }

Type guard

boolean isUpdatable(ResultSet rs) throws SQLException { return rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE; }

Try / catch

try { rs.updateByte(4, (byte) 9); rs.updateRow(); } catch (SQLFeatureNotSupportedException e) { /* UPDATE item SET qty = ? WHERE id = ? */ }

Prevention

When it happens

Trigger: Calling ResultSet.updateByte(columnIndex, (byte) x) on a federation ResultSet — editing a TINYINT/small-integer column client-side via the updatable-ResultSet protocol.

Common situations: Generic JDBC table editors that iterate updateXXX overloads matched to column types; ORM rowset implementations; code written against MySQL/Oracle updatable cursors reused under federation.

Related errors


AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14). Data as JSON: /api/errors/5330d472ca32e0dc. Report an issue: GitHub.

Appendix: source

Thrown at kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java:64

    
    @Override
    public final void updateNull(final String columnLabel) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateNull");
    }
    
    @Override
    public final void updateBoolean(final int columnIndex, final boolean x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateBoolean");
    }
    
    @Override
    public final void updateBoolean(final String columnLabel, final boolean x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateBoolean");
    }
    
    @Override
    public final void updateByte(final int columnIndex, final byte x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateByte");
    }
    
    @Override
    public final void updateByte(final String columnLabel, final byte x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateByte");
    }
    
    @Override
    public final void updateShort(final int columnIndex, final short x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateShort");
    }
    
    @Override
    public final void updateShort(final String columnLabel, final short x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateShort");
    }
    
    @Override

View on GitHub (pinned to e952770a21)