apache/shardingsphere · error · SQLFeatureNotSupportedException
setNCharacterStream
Error message
setNCharacterStream
What it means
SQLFeatureNotSupportedException('setNCharacterStream') thrown by AbstractUnsupportedOperationPreparedStatement.setNCharacterStream(int, Reader). The national-character streaming bind is not part of ShardingSphere's parameter pipeline; it forwards only the standard setCharacterStream family to routed backend statements, so this final method always throws.
Source
Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationPreparedStatement.java:69
@Override
public final void setNClob(final int parameterIndex, final NClob x) throws SQLException {
throw new SQLFeatureNotSupportedException("setNClob");
}
@Override
public final void setNClob(final int parameterIndex, final Reader x) throws SQLException {
throw new SQLFeatureNotSupportedException("setNClob");
}
@Override
public final void setNClob(final int parameterIndex, final Reader x, final long length) throws SQLException {
throw new SQLFeatureNotSupportedException("setNClob");
}
@Override
public final void setNCharacterStream(final int parameterIndex, final Reader x) throws SQLException {
throw new SQLFeatureNotSupportedException("setNCharacterStream");
}
@Override
public final void setNCharacterStream(final int parameterIndex, final Reader x, final long length) throws SQLException {
throw new SQLFeatureNotSupportedException("setNCharacterStream");
}
@Override
public final void setRowId(final int parameterIndex, final RowId x) throws SQLException {
throw new SQLFeatureNotSupportedException("setRowId");
}
@Override
public final void setRef(final int parameterIndex, final Ref x) throws SQLException {
throw new SQLFeatureNotSupportedException("setRef");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Replace with ps.setCharacterStream(1, reader).
- Disable nationalized character handling in your ORM (e.g. Hibernate hibernate.use_nationalized_character_data=false, remove @Nationalized).
- Verify the backend database encoding is UTF-8/utf8mb4 so plain character streams carry the same data.
Example fix
// before ps.setNCharacterStream(1, reader); // after ps.setCharacterStream(1, reader);
Defensive patterns
Strategy: fallback
Validate before calling
ps.setCharacterStream(idx, reader); // instead of setNCharacterStream(idx, reader)
Prevention
- No setN* method works on ShardingSphere PreparedStatement
- Use setCharacterStream for all streamed text
- Verify database character_set settings make N binds unnecessary
When it happens
Trigger: ps.setNCharacterStream(1, reader) on a ShardingSphere PreparedStatement; usually generic code that chooses the N-variant for any Reader, or explicit NCHAR streaming for Oracle/SQL Server schemas.
Common situations: Unicode text ingestion pipelines (CSV/XML importers) built with the N-methods on a previous driver; ORM nationalized character-stream type handlers active after enabling ShardingSphere.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/0dacaf72ffd64223.
Report an issue: GitHub.