apache/shardingsphere · error · SQLFeatureNotSupportedException
getNCharacterStream
Error message
getNCharacterStream
What it means
getNCharacterStream(int columnIndex) is final in AbstractUnsupportedOperationResultSet and always throws SQLFeatureNotSupportedException. The sharding driver does not expose national-character columns through the N-specific streaming accessor on its merged ResultSet.
Source
Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java:165
@Override
public final int getHoldability() throws SQLException {
throw new SQLFeatureNotSupportedException("getHoldability");
}
@Override
public final NClob getNClob(final int columnIndex) throws SQLException {
throw new SQLFeatureNotSupportedException("getNClob");
}
@Override
public final NClob getNClob(final String columnLabel) throws SQLException {
throw new SQLFeatureNotSupportedException("getNClob");
}
@Override
public final Reader getNCharacterStream(final int columnIndex) throws SQLException {
throw new SQLFeatureNotSupportedException("getNCharacterStream");
}
@Override
public final Reader getNCharacterStream(final String columnLabel) throws SQLException {
throw new SQLFeatureNotSupportedException("getNCharacterStream");
}
@Override
public final Ref getRef(final int columnIndex) throws SQLException {
throw new SQLFeatureNotSupportedException("getRef");
}
@Override
public final Ref getRef(final String columnLabel) throws SQLException {
throw new SQLFeatureNotSupportedException("getRef");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Use getCharacterStream(columnIndex) (or getString) instead — the regular character stream accessor is supported and returns the same text.
- Wrap the returned Reader for your streaming pipeline; for repeated small reads, getString is simpler.
- Update mapper type handlers to prefer non-N accessors under this driver.
Example fix
// before Reader reader = rs.getNCharacterStream(3); // throws // after Reader reader = rs.getCharacterStream(3);
Defensive patterns
Strategy: fallback
Validate before calling
Reader reader = rs.getCharacterStream(col); // same text, supported accessor
Try / catch
try {
reader = rs.getNCharacterStream(col);
} catch (SQLFeatureNotSupportedException e) {
reader = rs.getCharacterStream(col);
} Prevention
- Always stream national-character data via getCharacterStream/getString.
- Type handlers should map NCLOB/NVARCHAR to the plain character-stream path.
- Unit-test large-value streaming against the sharding driver.
When it happens
Trigger: Calling ResultSet.getNCharacterStream(columnIndex) on a ResultSet from ShardingSphereDataSource — usually in streaming readers for large NCHAR/NVARCHAR/NCLOB data or type-dispatching row mappers.
Common situations: Large national-character column handling written against Oracle/SQL Server drivers; common-dbutils/ORM type handlers that pick getNCharacterStream for Types.NCLOB/NVARCHAR; migration to the sharding URL without auditing N-accessor usage.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/b27f1a0321be518e.
Report an issue: GitHub.