prestodb/presto · warning · SQLFeatureNotSupportedException

setNCharacterStream

Error message

setNCharacterStream

What it means

PrestoPreparedStatement.setNCharacterStream is a stub throwing SQLFeatureNotSupportedException. The driver does not support the JDBC national-character-stream APIs used for NCHAR/NVARCHAR streaming input. Presto strings are UTF-8, so the national-character variants are unnecessary and unimplemented.

Source

Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoPreparedStatement.java:582

    @Override
    public void setRowId(int parameterIndex, RowId x)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("setRowId");
    }

    @Override
    public void setNString(int parameterIndex, String value)
            throws SQLException
    {
        setString(parameterIndex, value);
    }

    @Override
    public void setNCharacterStream(int parameterIndex, Reader value, long length)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("setNCharacterStream");
    }

    @Override
    public void setNClob(int parameterIndex, NClob value)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("setNClob");
    }

    @Override
    public void setClob(int parameterIndex, Reader reader, long length)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("setClob");
    }

    @Override
    public void setBlob(int parameterIndex, InputStream inputStream, long length)

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Use setCharacterStream(int, Reader, long) instead of the N-variant
  2. Read the Reader into a String and bind with setString for smaller values
  3. Normalize the mapping layer so Presto VARCHAR columns map to standard setString/setCharacterStream

Example fix

// before
pstmt.setNCharacterStream(1, reader, length);
// after
pstmt.setCharacterStream(1, reader, length);
Defensive patterns

Strategy: fallback

Validate before calling

if (targetType == Types.NCHAR || targetType == Types.NVARCHAR || targetType == Types.LONGNVARCHAR) { targetType = Types.VARCHAR; } // normalize before choosing setter

Type guard

boolean isNationalCharType(int sqlType) { return sqlType == Types.NCHAR || sqlType == Types.NVARCHAR || sqlType == Types.LONGNVARCHAR; }

Try / catch

try { pstmt.setNCharacterStream(idx, reader, len); } catch (SQLFeatureNotSupportedException e) { pstmt.setCharacterStream(idx, reader, len); }

Prevention

When it happens

Trigger: Calling PreparedStatement.setNCharacterStream(int, Reader, long) on a PrestoPreparedStatement; drivers/generic code paths that choose setNCharacterStream when the target is an NCHAR/NVARCHAR/LONGNVARCHAR column.

Common situations: Code written for SQL Server or Oracle national character columns reused against Presto; ORM mappings that stream large text via setNCharacterStream.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/e301f44fab588d7c. Report an issue: GitHub.