prestodb/presto · error · SQLFeatureNotSupportedException
setAsciiStream
Error message
setAsciiStream
What it means
The no-length variant PreparedStatement.setAsciiStream(int, InputStream) is unsupported in Presto's JDBC driver and throws SQLFeatureNotSupportedException. Unlike the length variants (which throw NotImplementedException), this JDBC 4 API is marked as a feature the driver intentionally does not support.
Source
Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoPreparedStatement.java:652
@Override
public void setBinaryStream(int parameterIndex, InputStream x, long length)
throws SQLException
{
throw new NotImplementedException("PreparedStatement", "setBinaryStream");
}
@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)View on GitHub (pinned to 55bb57d202)
Solutions
- Convert the InputStream to a String and call setString(parameterIndex, value)
- Use the length-based APIs — note they also throw NotImplementedException in this driver, so avoid all stream setters
- Pass the text value via setObject
- Restrict to supported types: primitives, String, byte[], java.sql types
Example fix
// before ps.setAsciiStream(1, in); // after ps.setString(1, new String(in.readAllBytes(), StandardCharsets.US_ASCII));
Defensive patterns
Strategy: try-catch
Validate before calling
if (value instanceof InputStream) {
throw new IllegalStateException("Presto JDBC does not support setAsciiStream; use setString");
} 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.setAsciiStream(idx, is);
} catch (SQLFeatureNotSupportedException e) {
ps.setString(idx, new String(is.readAllBytes(), StandardCharsets.US_ASCII));
} Prevention
- Avoid JDBC 4 length-less stream setters with Presto
- Wrap binding in a helper that only exposes supported setters
- Grep your codebase for setAsciiStream/setBinaryStream/setCharacterStream usages
- Keep Presto bindings in a separate code path from other databases
When it happens
Trigger: Calling PreparedStatement.setAsciiStream(parameterIndex, inputStream) (no length argument) on a PrestoPreparedStatement.
Common situations: JDBC 4.x style code omitting the length parameter; libraries that prefer the length-less stream setters when available.
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/03f9437e97e6c7d8.
Report an issue: GitHub.