apache/shardingsphere · error · SQLFeatureNotSupportedException

updateCharacterStream

Error message

updateCharacterStream

What it means

The federation ResultSet throws SQLFeatureNotSupportedException("updateCharacterStream") from the two-argument updateCharacterStream(int, Reader). Character-stream positioned updates are part of the JDBC row-update API, which SQL federation deliberately does not support: its result sets are merged, read-only views over shard query results, and every update method in AbstractUnsupportedUpdateOperationSQLFederationResultSet is a final throwing stub.

Source

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

    
    @Override
    public final void updateBinaryStream(final String columnLabel, final InputStream x, final int length) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateBinaryStream");
    }
    
    @Override
    public final void updateBinaryStream(final int columnIndex, final InputStream x, final long length) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateBinaryStream");
    }
    
    @Override
    public final void updateBinaryStream(final String columnLabel, final InputStream x, final long length) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateBinaryStream");
    }
    
    @Override
    public final void updateCharacterStream(final int columnIndex, final Reader x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateCharacterStream");
    }
    
    @Override
    public final void updateCharacterStream(final String columnLabel, final Reader x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateCharacterStream");
    }
    
    @Override
    public final void updateCharacterStream(final int columnIndex, final Reader x, final int length) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateCharacterStream");
    }
    
    @Override
    public final void updateCharacterStream(final String columnLabel, final Reader reader, final int length) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateCharacterStream");
    }
    
    @Override

View on GitHub (pinned to e952770a21)

Solutions

  1. Use a PreparedStatement UPDATE with setCharacterStream instead.
  2. Rewrite the query or adjust sharding/federation rules so it does not go through federation.
  3. Remove all ResultSet.update* usage from the codebase in favor of statement-based writes.

Example fix

// before
rs.updateCharacterStream(1, reader); // throws
rs.updateRow();

// after
PreparedStatement ps = conn.prepareStatement("UPDATE t_article SET body = ? WHERE id = ?");
ps.setCharacterStream(1, reader);
ps.setLong(2, id);
ps.executeUpdate();
Defensive patterns

Strategy: try-catch

Validate before calling

if (rs.getConcurrency() != ResultSet.CONCUR_UPDATABLE
        || rs instanceof org.apache.shardingsphere.sqlfederation.resultset.SQLFederationResultSet) {
    // use UPDATE + setCharacterStream instead
}

Type guard

boolean isFederationResultSet(ResultSet rs) {
    return rs instanceof org.apache.shardingsphere.sqlfederation.resultset.SQLFederationResultSet;
}

Try / catch

try {
    rs.updateCharacterStream(col, reader);
} catch (SQLFeatureNotSupportedException e) {
    // fall back to PreparedStatement UPDATE with setCharacterStream
}

Prevention

When it happens

Trigger: Calling rs.updateCharacterStream(columnIndex, reader) (no length) on a federation result set — typically writing CLOB/TEXT content — followed by rs.updateRow().

Common situations: Applications updating TEXT columns via Reader streams with positioned updates; sql_federation enabled in ShardingSphere config so JOINs/subqueries return federation result sets; code ported from direct database connections whose drivers permitted updatable result sets.

Related errors


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