prestodb/presto · error · SQLException

No wrapper for

Error message

No wrapper for 

What it means

unwrap(iface) in PrestoDatabaseMetaData throws SQLException('No wrapper for ' + iface) when the requested interface is not one this object implements or wraps. Per the JDBC Wrapper contract, PrestoDatabaseMetaData only unwraps itself (or interfaces it directly implements, e.g. DatabaseMetaData); asking for any other vendor extension interface fails.

Source

Thrown at presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoDatabaseMetaData.java:1405

                "ORDER BY TABLE_CAT, table_SCHEM, TABLE_NAME, COLUMN_NAME");
    }

    @Override
    public boolean generatedKeyAlwaysReturned()
            throws SQLException
    {
        return false;
    }

    @SuppressWarnings("unchecked")
    @Override
    public <T> T unwrap(Class<T> iface)
            throws SQLException
    {
        if (isWrapperFor(iface)) {
            return (T) this;
        }
        throw new SQLException("No wrapper for " + iface);
    }

    @Override
    public boolean isWrapperFor(Class<?> iface)
            throws SQLException
    {
        return iface.isInstance(this);
    }

    private ResultSet selectEmpty(String sql)
            throws SQLException
    {
        return select(sql + " LIMIT 0");
    }

    private ResultSet select(String sql)
            throws SQLException
    {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Only unwrap to interfaces PrestoDatabaseMetaData actually implements (it returns itself)
  2. Call isWrapperFor(iface) first and handle false without invoking unwrap
  3. Remove vendor-specific unwrapping when using Presto; code against java.sql interfaces
  4. Use reflection-free feature detection (DatabaseMetaData.supportsX) instead of driver-specific casts

Example fix

// before
VendorMeta vm = (VendorMeta) meta.unwrap(VendorMeta.class); // throws
// after
if (meta.isWrapperFor(VendorMeta.class)) {
    VendorMeta vm = meta.unwrap(VendorMeta.class);
} else {
    // fall back to standard java.sql.DatabaseMetaData usage
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (!meta.isWrapperFor(iface)) { /* skip unwrap, use java.sql API directly */ }

Type guard

boolean unwrappable = iface != null && meta.isWrapperFor(iface);

Try / catch

try { return meta.unwrap(iface); } catch (SQLException e) { if (e.getMessage().startsWith("No wrapper for")) { return fallbackToStandardApi(); } throw e; }

Prevention

When it happens

Trigger: Calling ((SomeVendorInterface) meta.unwrap(SomeVendorInterface.class)) where SomeVendorInterface is not implemented by PrestoDatabaseMetaData — e.g. unwrapping to a native connection or vendor metadata extension.

Common situations: Pooling frameworks (HikariCP, DBCP) that unwrap statements/metadata to vendor types, code written against Oracle/MySQL driver extensions being reused with Presto.

Related errors


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