prestodb/presto · error · SQLFeatureNotSupportedException
setArray
Error message
setArray
What it means
setArray is unconditionally unsupported in PrestoPreparedStatement: any call throws SQLFeatureNotSupportedException because java.sql.Array handles are not implemented. Array-typed parameters must be expressed differently (e.g. as literal text) in this driver.
Source
Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoPreparedStatement.java:510
@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()
throws SQLException
{
try (Statement statement = connection().createStatement(); ResultSet resultSet = statement.executeQuery("DESCRIBE OUTPUT " + statementName)) {
return new PrestoResultSetMetaData(getDescribeOutputColumnInfoList(resultSet));
}
}
@Override
public void setDate(int parameterIndex, Date x, Calendar cal)
throws SQLException
{
throw new NotImplementedException("PreparedStatement", "setDate");
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Serialize the collection to a JSON string (e.g. Jackson) and cast in SQL: CAST(? AS ARRAY<type>).
- Bind each array element as separate scalar parameters if the size is fixed.
- Use connection.createArrayOf if supported by your driver version, else avoid Array objects.
Example fix
// before
ps.setArray(1, conn.createArrayOf("int", ints));
// after
String json = new ObjectMapper().writeValueAsString(ints);
ps.setString(1, json); // CAST(? AS ARRAY<BIGINT>) in SQL Defensive patterns
Strategy: fallback
Validate before calling
if (x instanceof java.sql.Array) { throw new IllegalArgumentException("pass array as JSON string with CAST in SQL instead"); } Try / catch
try { ps.setArray(1, arr); } catch (SQLFeatureNotSupportedException e) { ps.setString(1, toJson(list)); /* CAST(? AS ARRAY<T>) */ } Prevention
- Bind Presto ARRAY columns via JSON string + CAST(? AS ARRAY<type>)
- Expand fixed-size arrays into individual scalar parameters
- Avoid java.sql.Array with Presto JDBC
When it happens
Trigger: Calling PreparedStatement.setArray(int, Array) on a Presto connection.
Common situations: Trying to insert into Presto ARRAY columns using JDBC Array objects created from another connection or connection.createArrayOf.
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/9f309eca3f7f56d1.
Report an issue: GitHub.