prestodb/presto · error · SQLFeatureNotSupportedException

setBinaryStream

Error message

setBinaryStream

What it means

The length-less PreparedStatement.setBinaryStream(int, InputStream) is unsupported in Presto's JDBC driver and throws SQLFeatureNotSupportedException. Binary data cannot be streamed into parameters; the driver only accepts concrete values.

Source

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

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

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

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

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

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

    @Override
    public void setClob(int parameterIndex, Reader reader)

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Read the InputStream fully into a byte[] and call setBytes(parameterIndex, bytes)
  2. Use setObject(parameterIndex, byteArray)
  3. Store large binaries outside Presto and reference them by path/URI in a VARCHAR parameter
  4. Add a capability check before using any stream setter with this driver

Example fix

// before
ps.setBinaryStream(1, in);
// after
ps.setBytes(1, in.readAllBytes());
Defensive patterns

Strategy: try-catch

Validate before calling

if (value instanceof InputStream) {
    throw new IllegalStateException("Presto JDBC does not support setBinaryStream; use setBytes");
}

Type guard

boolean isSupportedParamType(Object v) {
    return v instanceof String || v instanceof Number || v instanceof Boolean
        || v instanceof byte[] || v instanceof java.sql.Date
        || v instanceof java.sql.Time || v instanceof java.sql.Timestamp;
}

Try / catch

try {
    ps.setBinaryStream(idx, is);
} catch (SQLFeatureNotSupportedException e) {
    ps.setBytes(idx, is.readAllBytes());
}

Prevention

When it happens

Trigger: Calling PreparedStatement.setBinaryStream(parameterIndex, inputStream) on a PrestoPreparedStatement.

Common situations: JDBC 4 code paths that skip the length argument; generic data-loading tools streaming binary columns.

Related errors


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