prestodb/presto · error · SQLFeatureNotSupportedException

prepareStatement

Error message

prepareStatement

What it means

PrestoConnection does not implement the JDBC 4.x prepareStatement(String sql, String[] columnNames) overload for auto-generated key column names. It unconditionally throws SQLFeatureNotSupportedException with message "prepareStatement".

Source

Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoConnection.java:498

    {
        if (autoGeneratedKeys != Statement.RETURN_GENERATED_KEYS) {
            throw new SQLFeatureNotSupportedException("Auto generated keys must be NO_GENERATED_KEYS");
        }
        return prepareStatement(sql);
    }

    @Override
    public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("prepareStatement");
    }

    @Override
    public PreparedStatement prepareStatement(String sql, String[] columnNames)
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("prepareStatement");
    }

    @Override
    public Clob createClob()
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("createClob");
    }

    @Override
    public Blob createBlob()
            throws SQLException
    {
        throw new SQLFeatureNotSupportedException("createBlob");
    }

    @Override
    public NClob createNClob()

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Use the simple prepareStatement(String sql) or prepareStatement(String, int) (Statement.RETURN_GENERATED_KEYS) overloads if applicable
  2. Remove reliance on generated-key column names — Presto does not return auto-generated keys like OLTP databases
  3. If using an ORM, configure it to not request generated keys via column names (e.g. disable getGeneratedKeys)

Example fix

// before
PreparedStatement ps = conn.prepareStatement(sql, new String[]{"id"});
// after
PreparedStatement ps = conn.prepareStatement(sql);
Defensive patterns

Strategy: try-catch

Validate before calling

if (columnNames != null) {
    throw new UnsupportedOperationException("Presto JDBC does not support prepareStatement(sql, columnNames)");
}

Try / catch

PreparedStatement ps;
try {
    ps = conn.prepareStatement(sql, columnNames);
} catch (SQLFeatureNotSupportedException e) {
    ps = conn.prepareStatement(sql); // Presto does not return generated keys
}

Prevention

When it happens

Trigger: Calling connection.prepareStatement(sql, new String[]{"id"}) (or any non-null columnNames array) on a Presto JDBC connection.

Common situations: ORM frameworks (e.g. Hibernate with getGeneratedKeys by column) or generic JDBC code that uses the columnNames overload; porting an application from MySQL/PostgreSQL drivers to Presto JDBC.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/cd2665be73a6d958. Report an issue: GitHub.