apache/shardingsphere · error · SQLFeatureNotSupportedException

updateNull

Error message

updateNull

What it means

ShardingSphere federation ResultSets are read-only: they materialize federated query output in memory, so JDBC row-updater updateNull(int) is explicitly forbidden. The method is final in AbstractUnsupportedUpdateOperationSQLFederationResultSet and throws SQLFeatureNotSupportedException on every call.

Source

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

import java.sql.Date;
import java.sql.NClob;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLXML;
import java.sql.Time;
import java.sql.Timestamp;

/**
 * Unsupported {@code ResultSet} update methods for SQL federation.
 */
public abstract class AbstractUnsupportedUpdateOperationSQLFederationResultSet extends SQLFederationWrapperAdapter implements ResultSet {
    
    @Override
    public final void updateNull(final int columnIndex) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateNull");
    }
    
    @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

View on GitHub (pinned to e952770a21)

Solutions

  1. Replace in-place updates with an explicit UPDATE ... SET col = NULL statement executed through ShardingSphere normally.
  2. Check rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE before calling update methods and fall back to SQL updates.
  3. Do not enable federation for statements used by updatable-ResultSet tooling; route them to a plain datasource.
  4. File a feature request if updatable federated results are a product requirement.

Example fix

// before
resultSet.updateNull(3);
resultSet.updateRow();

// after
// close the ResultSet and run:
// UPDATE t SET col3 = NULL WHERE id = ?
Defensive patterns

Strategy: validation

Validate before calling

if (resultSet.getConcurrency() != ResultSet.CONCUR_UPDATABLE) { throw new IllegalStateException("read-only result set; use UPDATE SQL"); }

Type guard

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

Try / catch

try { rs.updateNull(1); rs.updateRow(); } catch (SQLFeatureNotSupportedException e) { /* fall back to UPDATE SQL */ }

Prevention

When it happens

Trigger: Calling ResultSet.updateNull(int columnIndex) on a federation ResultSet — i.e. any attempt to modify a row in place (updatable ResultSet pattern) instead of issuing an UPDATE statement. Requires a ResultSet with CONCUR_UPDATABLE semantics in normal JDBC.

Common situations: Code assuming updatable ResultSets (JDBC rowset editing, GUI table editors, some legacy DAO frameworks); enabling sql-federation on a datasource used by tools that call updateXXX/updateRow; migration from a driver where CONCUR_UPDATABLE worked.

Related errors


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