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
- Read the InputStream fully into a byte[] and call setBytes(parameterIndex, bytes)
- Use setObject(parameterIndex, byteArray)
- Store large binaries outside Presto and reference them by path/URI in a VARCHAR parameter
- 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
- Bind binary data as byte[] with setBytes for Presto VARBINARY columns
- Store large binaries in object storage, not in Presto tables
- Avoid generic JDBC data-loading frameworks that default to stream setters
- Add integration tests covering all parameter types your code binds
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
- 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/b364388a73bb2e9c.
Report an issue: GitHub.