prestodb/presto · error · SQLException

No wrapper for

Error message

No wrapper for 

What it means

unwrap(Class) throws SQLException("No wrapper for " + iface) when isWrapperFor(iface) is false — i.e. PrestoConnection neither implements the requested interface nor wraps an object that does. The message includes the offending Class object. This is a local argument/capability failure, not a server issue.

Source

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

    }

    @Override
    public int getNetworkTimeout()
            throws SQLException
    {
        checkOpen();
        return networkTimeoutMillis.get();
    }

    @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);
    }

    URI getURI()
    {
        return jdbcUri;
    }

    String getUser()
    {
        return user;
    }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Check conn.isWrapperFor(iface) first and handle the false branch
  2. Unwrap the pool's proxy to java.sql.Connection before any driver-specific unwrap
  3. Only request interfaces PrestoConnection actually implements (Wrapper/Connection/AutoCloseable/PrestoConnection)

Example fix

// before
PrestoConnection pc = conn.unwrap(PrestoConnection.class); // throws if not Presto
// after
if (conn.isWrapperFor(PrestoConnection.class)) {
    PrestoConnection pc = conn.unwrap(PrestoConnection.class);
} else {
    // handle non-Presto connection
}
Defensive patterns

Strategy: validation

Validate before calling

if (!connection.isWrapperFor(iface)) {
    // not supported: handle before calling unwrap
}
Object unwrapped = connection.unwrap(iface);

Type guard

static <T> Optional<T> safeUnwrap(Connection c, Class<T> iface) {
    try {
        return c.isWrapperFor(iface)
            ? Optional.of(iface.cast(c.unwrap(iface)))
            : Optional.empty();
    } catch (SQLException e) {
        return Optional.empty();
    }
}

Prevention

When it happens

Trigger: conn.unwrap(SomeVendorInterface.class) on a PrestoConnection; unwrapping a pooled proxy to a driver-specific type that the proxy itself does not handle; requesting interfaces only other drivers implement (e.g. OracleConnection).

Common situations: Generic code that unwraps to native connections under HikariCP/DBCP; copy-pasted vendor-specific unwrap calls after switching drivers.

Related errors


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