prestodb/presto · error · SQLFeatureNotSupportedException
getNCharacterStream
Error message
getNCharacterStream
What it means
PrestoResultSet.getNCharacterStream(int) is a JDBC 4 national-character stream accessor that Presto's driver intentionally does not support; it throws SQLFeatureNotSupportedException naming the method. Presto has no NCHAR-family SQL types, so no character-stream implementation exists.
Source
Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSet.java:1412
@Override
public String getNString(int columnIndex)
throws SQLException
{
throw new SQLFeatureNotSupportedException("getNString");
}
@Override
public String getNString(String columnLabel)
throws SQLException
{
throw new SQLFeatureNotSupportedException("getNString");
}
@Override
public Reader getNCharacterStream(int columnIndex)
throws SQLException
{
throw new SQLFeatureNotSupportedException("getNCharacterStream");
}
@Override
public Reader getNCharacterStream(String columnLabel)
throws SQLException
{
throw new SQLFeatureNotSupportedException("getNCharacterStream");
}
@Override
public void updateNCharacterStream(int columnIndex, Reader x, long length)
throws SQLException
{
throw new SQLFeatureNotSupportedException("updateNCharacterStream");
}
@Override
public void updateNCharacterStream(String columnLabel, Reader reader, long length)View on GitHub (pinned to 55bb57d202)
Solutions
- Use getCharacterStream(int columnIndex) if a stream is needed, or getString for the full text
- Refactor the data-access layer to the standard character APIs supported by Presto
- Check driver capability (DatabaseMetaData) before calling JDBC 4-only methods
Example fix
// before Reader r = rs.getNCharacterStream(3); // after Reader r = rs.getCharacterStream(3);
Defensive patterns
Strategy: try-catch
Validate before calling
if (conn.getMetaData().getDatabaseProductName().contains("Presto")) {
useStandardCharStream = true;
} Type guard
boolean supportsNCharStream(ResultSet rs) {
return !(rs instanceof com.facebook.presto.jdbc.PrestoResultSet);
} Try / catch
try {
reader = rs.getNCharacterStream(3);
} catch (SQLFeatureNotSupportedException e) {
reader = rs.getCharacterStream(3);
} Prevention
- Prefer getCharacterStream over getNCharacterStream for all Presto reads
- Audit JDBC 4 usage in shared mappers against Presto's supported subset
- Feature-detect via DatabaseMetaData before calling N* stream APIs
When it happens
Trigger: Calling getNCharacterStream(int columnIndex) on a Presto result set. Throws unconditionally on every invocation.
Common situations: Generic JDBC tooling or code ported from databases with national character types; readers streaming large text columns assuming JDBC 4 N-stream APIs are available.
Related errors
- Result set type must be TYPE_FORWARD_ONLY
- Result set concurrency must be CONCUR_READ_ONLY
- Result set holdability must be HOLD_CURSORS_OVER_COMMIT
- privileges not supported
- row identifiers not supported
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/b8886ff4d5025afd.
Report an issue: GitHub.