prestodb/presto · error · SQLFeatureNotSupportedException

setRef

Error message

setRef

What it means

setRef is unconditionally unsupported in PrestoPreparedStatement: any call throws SQLFeatureNotSupportedException. Presto has no SQL REF type or locator-based reference support, so the driver rejects the JDBC interface method regardless of arguments.

Source

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

            return batchUpdateCounts;
        }
        finally {
            clearBatch();
        }
    }

    @Override
    public void setCharacterStream(int parameterIndex, Reader reader, int length)
            throws SQLException
    {
        throw new NotImplementedException("PreparedStatement", "setCharacterStream");
    }

    @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)

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Remove the REF usage; Presto has no ref-cursor parameters.
  2. Model the data with regular query results / result sets instead.
  3. Bind a supported type (e.g. the referenced value itself) via setString/setLong.

Example fix

// before
ps.setRef(1, ref);
// after
ps.setString(1, referencedValue);
Defensive patterns

Strategy: validation

Validate before calling

if (x instanceof java.sql.Ref) throw new IllegalArgumentException("Presto JDBC does not support Ref parameters");

Type guard

static boolean isRefParam(Object x) { return x instanceof java.sql.Ref; }

Try / catch

try { ps.setRef(1, ref); } catch (SQLFeatureNotSupportedException e) { /* rewrite binding with a supported type */ }

Prevention

When it happens

Trigger: Calling PreparedStatement.setRef(int, Ref) on a Presto connection.

Common situations: Legacy code ported from Oracle/DB2 that uses REF CURSOR types.

Related errors


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