{"record":{"id":"4319b1be88782a48","repo":"prestodb/presto","slug":"no-wrapper-for","errorCode":null,"errorMessage":"No wrapper for ","messagePattern":"No wrapper for ","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoConnection.java","lineNumber":703,"sourceCode":"    }\n\n    @Override\n    public int getNetworkTimeout()\n            throws SQLException\n    {\n        checkOpen();\n        return networkTimeoutMillis.get();\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public <T> T unwrap(Class<T> iface)\n            throws SQLException\n    {\n        if (isWrapperFor(iface)) {\n            return (T) this;\n        }\n        throw new SQLException(\"No wrapper for \" + iface);\n    }\n\n    @Override\n    public boolean isWrapperFor(Class<?> iface)\n            throws SQLException\n    {\n        return iface.isInstance(this);\n    }\n\n    URI getURI()\n    {\n        return jdbcUri;\n    }\n\n    String getUser()\n    {\n        return user;\n    }","sourceCodeStart":685,"sourceCodeEnd":721,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoConnection.java#L685-L721","documentation":"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.","triggerScenarios":"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).","commonSituations":"Generic code that unwraps to native connections under HikariCP/DBCP; copy-pasted vendor-specific unwrap calls after switching drivers.","solutions":["Check conn.isWrapperFor(iface) first and handle the false branch","Unwrap the pool's proxy to java.sql.Connection before any driver-specific unwrap","Only request interfaces PrestoConnection actually implements (Wrapper/Connection/AutoCloseable/PrestoConnection)"],"exampleFix":"// before\nPrestoConnection pc = conn.unwrap(PrestoConnection.class); // throws if not Presto\n// after\nif (conn.isWrapperFor(PrestoConnection.class)) {\n    PrestoConnection pc = conn.unwrap(PrestoConnection.class);\n} else {\n    // handle non-Presto connection\n}","handlingStrategy":"validation","validationCode":"if (!connection.isWrapperFor(iface)) {\n    // not supported: handle before calling unwrap\n}\nObject unwrapped = connection.unwrap(iface);","typeGuard":"static <T> Optional<T> safeUnwrap(Connection c, Class<T> iface) {\n    try {\n        return c.isWrapperFor(iface)\n            ? Optional.of(iface.cast(c.unwrap(iface)))\n            : Optional.empty();\n    } catch (SQLException e) {\n        return Optional.empty();\n    }\n}","tryCatchPattern":null,"preventionTips":["Always call isWrapperFor before unwrap","Unwrap pool proxies to java.sql.Connection before driver-specific unwraps","Restrict driver-specific casts to code paths that know the driver is Presto"],"tags":["jdbc","presto","unwrap","type-mismatch"],"backgroundTag":"jdbc-unwrap-failed","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}