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
- Extract byte[] via blob.getBytes(1, (int) blob.length()) and call setBytes.
- Bind binary data as varbinary using setBytes instead of Blob.
- 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
- Bind binary data with setBytes(varbinary)
- Store large binaries outside Presto and reference by URL/path
- Avoid java.sql.Blob in Presto-targeting data-access code
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
- Result set type must be TYPE_FORWARD_ONLY
- Result set concurrency must be CONCUR_READ_ONLY
- Result set holdability must be HOLD_CURSORS_OVER_COMMIT
- privileges not supported
- row identifiers not supported
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/54757829b23239a2.
Report an issue: GitHub.