prestodb/presto · warning · SQLFeatureNotSupportedException

setNClob

Error message

setNClob

What it means

PrestoPreparedStatement.setNClob(int, NClob) is a stub throwing SQLFeatureNotSupportedException. The Presto JDBC driver does not support NClob locators or national-character large-object binding. Large text must be streamed or bound as a string using the non-N APIs.

Source

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

    @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)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("setBlob");
    }

    @Override
    public void setNClob(int parameterIndex, Reader reader, long length)

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Use setClob(int, Clob) or setCharacterStream for large text
  2. Bind the value with setString when the text fits in memory
  3. Strip the NClob wrapper and pass the underlying string/reader

Example fix

// before
pstmt.setNClob(1, nclob);
// after
pstmt.setString(1, nclob.getSubString(1, (int) nclob.length()));
Defensive patterns

Strategy: fallback

Validate before calling

if (value instanceof java.sql.NClob) { pstmt.setString(parameterIndex, ((java.sql.NClob) value).getSubString(1, (int) ((java.sql.NClob) value).length())); }

Type guard

boolean isLocatorType(Object v) { return v instanceof java.sql.NClob || v instanceof java.sql.Clob || v instanceof java.sql.Blob || v instanceof java.sql.SQLXML; }

Try / catch

try { pstmt.setNClob(idx, nclob); } catch (SQLFeatureNotSupportedException e) { pstmt.setString(idx, nclob.getSubString(1, (int) nclob.length())); }

Prevention

When it happens

Trigger: Calling PreparedStatement.setNClob(int parameterIndex, java.sql.NClob value) on a PrestoPreparedStatement; frameworks that wrap large text in NClob objects before binding.

Common situations: Code migrated from Oracle/SQL Server where NCLOB columns are common; generic JDBC exporters that wrap CLOB/NCLOB values for cross-database copies.

Related errors


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