prestodb/presto · error · SQLFeatureNotSupportedException

setBlob

Error message

setBlob

What it means

setBlob is unconditionally unsupported in PrestoPreparedStatement: any call throws SQLFeatureNotSupportedException because the driver has no BLOB locator support. Binary data must be bound with setBytes instead of a java.sql.Blob handle.

Source

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

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

    @Override
    public ResultSetMetaData getMetaData()

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Extract byte[] via blob.getBytes(1, (int) blob.length()) and call setBytes.
  2. Bind binary data as varbinary using setBytes instead of Blob.
  3. Store large binaries externally and insert a reference/URL string.

Example fix

// before
ps.setBlob(1, blob);
// after
ps.setBytes(1, blob.getBytes(1, (int) blob.length()));
Defensive patterns

Strategy: fallback

Validate before calling

if (x instanceof java.sql.Blob) { byte[] bytes = x.getBytes(1, (int) x.length()); ps.setBytes(1, bytes); return; }

Try / catch

try { ps.setBlob(1, blob); } catch (SQLFeatureNotSupportedException e) { ps.setBytes(1, blob.getBytes(1, (int) blob.length())); }

Prevention

When it happens

Trigger: Calling PreparedStatement.setBlob(int, Blob) on a Presto connection.

Common situations: Inserting binary data (images, files) ported from other databases' JDBC drivers.

Related errors


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