prestodb/presto · error · SQLFeatureNotSupportedException

setClob

Error message

setClob

What it means

setClob is unconditionally unsupported in PrestoPreparedStatement: any call throws SQLFeatureNotSupportedException. The driver cannot accept java.sql.Clob handles; character large values must be passed as String via setString.

Source

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

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

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

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

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

    @Override
    public ResultSetMetaData getMetaData()
            throws SQLException
    {
        try (Statement statement = connection().createStatement(); ResultSet resultSet = statement.executeQuery("DESCRIBE OUTPUT " + statementName)) {
            return new PrestoResultSetMetaData(getDescribeOutputColumnInfoList(resultSet));
        }
    }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Convert the Clob to a String (clob.getSubString(1, (int) clob.length())) and call setString.
  2. For very large text, read the Clob's character stream into a String then setString.
  3. Avoid Clob entirely in code targeting Presto.

Example fix

// before
ps.setClob(1, clob);
// after
ps.setString(1, clob.getSubString(1, (int) clob.length()));
Defensive patterns

Strategy: fallback

Validate before calling

if (x instanceof java.sql.Clob) { ps.setString(1, x.getSubString(1, (int) x.length())); return; }

Try / catch

try { ps.setClob(1, clob); } catch (SQLFeatureNotSupportedException e) { ps.setString(1, clob.getSubString(1, (int) clob.length())); }

Prevention

When it happens

Trigger: Calling PreparedStatement.setClob(int, Clob) on a Presto connection.

Common situations: Porting large-text handling code from Oracle/MySQL that uses Clob for text columns.

Related errors


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