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");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Use a PreparedStatement UPDATE with setCharacterStream instead.
- Rewrite the query or adjust sharding/federation rules so it does not go through federation.
- 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
- Write TEXT/CLOB content via UPDATE statements with setCharacterStream.
- Never assume updatable cursors behind a federation or proxy layer.
- Add regression tests for text-update flows under ShardingSphere.
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
- Unexpected trailing bytes in BLR
- BLOB fields are not supported in Firebird batch operations
- Expected blr_short NULL indicator, got: %s
- Unsupported BLR type: %s
- updateNull
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/9c21f268673d89b0.
Report an issue: GitHub.