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.

Solutions

  1. Replace with ps.setCharacterStream(1, reader).
  2. Disable nationalized character handling in your ORM (e.g. Hibernate hibernate.use_nationalized_character_data=false, remove @Nationalized).
  3. 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

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.

Appendix: 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");
    }
    
    @Override

View on GitHub (pinned to e952770a21)