apache/shardingsphere · error · SQLFeatureNotSupportedException

updateShort

Error message

updateShort

What it means

updateShort(int, short) is part of the row-update API that AbstractUnsupportedUpdateOperationSQLFederationResultSet blocks by design. ShardingSphere federation computes results in memory and offers no writable cursor, so the final method always throws SQLFeatureNotSupportedException.

Source

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

    
    @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
    public final void updateInt(final int columnIndex, final int x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateInt");
    }
    
    @Override
    public final void updateInt(final String columnLabel, final int x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateInt");
    }
    
    @Override

View on GitHub (pinned to e952770a21)

Solutions

  1. Persist with an UPDATE statement using a PreparedStatement parameter for the short value.
  2. Treat CONCUR_READ_ONLY ResultSets as non-editable and take the SQL-update path automatically.
  3. Route statements used for interactive editing away from federation.
  4. Audit shared DAO code for any updateXXX( usage as part of the federation migration checklist.

Example fix

// before
resultSet.updateShort(2, (short) 42);
resultSet.updateRow();

// after
// UPDATE sensor SET threshold = ? WHERE id = ?
Defensive patterns

Strategy: validation

Validate before calling

if (resultSet.getConcurrency() != ResultSet.CONCUR_UPDATABLE) { /* use UPDATE SQL */ }

Type guard

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

Try / catch

try { rs.updateShort(2, (short) 42); rs.updateRow(); } catch (SQLFeatureNotSupportedException e) { /* UPDATE sensor SET threshold = ? WHERE id = ? */ }

Prevention

When it happens

Trigger: Calling ResultSet.updateShort(columnIndex, (short) v) (typically before updateRow()) on a federation ResultSet — an in-place edit of a SMALLINT-typed column.

Common situations: Framework code that maps JDBC TINYINT/SMALLINT metadata to updateShort; editable grid tools; porting desktop/JDBC-swing applications onto a sharded federation datasource.

Related errors


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