prestodb/presto · warning · SQLFeatureNotSupportedException
setObject
Error message
setObject
What it means
PrestoPreparedStatement.setObject(int, Object, int, int) — the four-argument variant with targetSqlType and scaleOrLength — is a stub throwing SQLFeatureNotSupportedException. The driver only supports simpler setObject forms; it cannot coerce an arbitrary object to an explicit SQL type with scale/length. The two-argument setObject(int, Object) delegates and callers often reach this from that path when it dispatches here.
Source
Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoPreparedStatement.java:624
@Override
public void setNClob(int parameterIndex, Reader reader, long length)
throws SQLException
{
throw new SQLFeatureNotSupportedException("setNClob");
}
@Override
public void setSQLXML(int parameterIndex, SQLXML xmlObject)
throws SQLException
{
throw new SQLFeatureNotSupportedException("setSQLXML");
}
@Override
public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength)
throws SQLException
{
throw new SQLFeatureNotSupportedException("setObject");
}
@Override
public void setAsciiStream(int parameterIndex, InputStream x, long length)
throws SQLException
{
throw new NotImplementedException("PreparedStatement", "setAsciiStream");
}
@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)View on GitHub (pinned to 55bb57d202)
Solutions
- Use the two-argument setObject(parameterIndex, x) and let the driver infer the type
- Bind typed values with dedicated setters: setBigDecimal, setTimestamp, setInt, etc.
- Pre-convert the value in application code to the exact type the driver supports, then bind it
- Upgrade the Presto JDBC driver to a version that may implement the typed setObject overloads
Example fix
// before pstmt.setObject(1, bigDecimalValue, Types.DECIMAL, 4); // after pstmt.setBigDecimal(1, bigDecimalValue.setScale(4, RoundingMode.HALF_UP));
Defensive patterns
Strategy: fallback
Validate before calling
if (x instanceof java.math.BigDecimal) pstmt.setBigDecimal(idx, (java.math.BigDecimal) x); else if (x instanceof java.sql.Timestamp) pstmt.setTimestamp(idx, (java.sql.Timestamp) x); else pstmt.setObject(idx, x); // 2-arg form only
Type guard
boolean hasDedicatedSetter(Object x) { return x instanceof String || x instanceof Number || x instanceof Boolean || x instanceof byte[] || x instanceof java.sql.Date || x instanceof java.sql.Time || x instanceof java.sql.Timestamp || x instanceof java.math.BigDecimal; } Try / catch
try { pstmt.setObject(idx, x, targetSqlType, scaleOrLength); } catch (SQLFeatureNotSupportedException e) { pstmt.setObject(idx, coerce(x, targetSqlType, scaleOrLength)); } Prevention
- Use the 2-argument setObject or typed setters (setBigDecimal, setTimestamp) against Presto
- Pre-scale BigDecimal values in application code instead of passing scaleOrLength
- Keep explicit Types.* coercion out of the shared Presto bind path
When it happens
Trigger: Calling PreparedStatement.setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) on a PrestoPreparedStatement; ORM/serialization layers that specify explicit Types.* targets and scale for DECIMAL or temporal bind values.
Common situations: JPA/Hibernate dialects binding BigDecimal with scale via the 4-arg setObject; query builders that pass java.sql.Timestamp with Types.TIMESTAMP through the 4-arg overload against Presto.
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/6009f88ba32f0d35.
Report an issue: GitHub.