apache/shardingsphere · error · SQLFeatureNotSupportedException
updateNCharacterStream
Error message
updateNCharacterStream
What it means
The federation ResultSet throws SQLFeatureNotSupportedException("updateNCharacterStream") from updateNCharacterStream(int, Reader). This is the JDBC 4.0 national-character-set variant of positioned updates; as with all update methods in AbstractUnsupportedUpdateOperationSQLFederationResultSet, it is a final stub that always throws because SQL federation results are read-only merged snapshots with no write-back to shards.
Source
Thrown at kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java:284
@Override
public final void updateCharacterStream(final String columnLabel, final Reader reader, final int length) throws SQLException {
throw new SQLFeatureNotSupportedException("updateCharacterStream");
}
@Override
public final void updateCharacterStream(final int columnIndex, final Reader x, final long length) throws SQLException {
throw new SQLFeatureNotSupportedException("updateCharacterStream");
}
@Override
public final void updateCharacterStream(final String columnLabel, final Reader reader, final long length) throws SQLException {
throw new SQLFeatureNotSupportedException("updateCharacterStream");
}
@Override
public final void updateNCharacterStream(final int columnIndex, final Reader x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateNCharacterStream");
}
@Override
public final void updateNCharacterStream(final String columnLabel, final Reader x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateNCharacterStream");
}
@Override
public final void updateNCharacterStream(final int columnIndex, final Reader x, final long length) throws SQLException {
throw new SQLFeatureNotSupportedException("updateNCharacterStream");
}
@Override
public final void updateNCharacterStream(final String columnLabel, final Reader x, final long length) throws SQLException {
throw new SQLFeatureNotSupportedException("updateNCharacterStream");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Write N-character data with an explicit UPDATE statement and setNCharacterStream.
- Avoid federation routing for this query by simplifying the SQL or adjusting sharding/federation configuration.
- Refactor update flows to statement-based writes throughout the persistence layer.
Example fix
// before
rs.updateNCharacterStream(3, nReader); // throws
rs.updateRow();
// after
PreparedStatement ps = conn.prepareStatement("UPDATE t_msg SET content = ? WHERE id = ?");
ps.setNCharacterStream(1, nReader);
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 + setNCharacterStream instead
} Type guard
boolean isFederationResultSet(ResultSet rs) {
return rs instanceof org.apache.shardingsphere.sqlfederation.resultset.SQLFederationResultSet;
} Try / catch
try {
rs.updateNCharacterStream(col, reader);
} catch (SQLFeatureNotSupportedException e) {
// fall back to PreparedStatement UPDATE with setNCharacterStream
} Prevention
- Use setNCharacterStream on statements for Unicode column writes.
- Never rely on positioned updates behind the federation engine.
- Verify N-character update flows with integration tests under ShardingSphere.
When it happens
Trigger: Calling rs.updateNCharacterStream(columnIndex, reader) (no length) on a federation result set — e.g. updating an NCHAR/NVARCHAR/NCLOB-typed column of a federated query row — before rs.updateRow().
Common situations: Applications using updateNCharacterStream for Unicode text columns (common on databases with national character types); ShardingSphere deployments with SQL federation enabled; ORMs or utilities that prefer N* JDBC methods for internationalized text.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/ceb13184cd3e91d9.
Report an issue: GitHub.