{"record":{"id":"7c3d162fb99ac92c","repo":"prestodb/presto","slug":"no-wrapper-for-7c3d16","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/PrestoResultSetMetaData.java","lineNumber":244,"sourceCode":"            case Types.BLOB:\n                return Blob.class.getName();\n            case Types.CLOB:\n                return Clob.class.getName();\n            case Types.ARRAY:\n                return Array.class.getName();\n        }\n        return String.class.getName();\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    private ColumnInfo column(int column)\n            throws SQLException\n    {\n        if ((column <= 0) || (column > columnInfo.size())) {\n            throw new SQLException(\"Invalid column index: \" + column);\n        }\n        return columnInfo.get(column - 1);\n    }\n}","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoResultSetMetaData.java#L226-L262","documentation":"Standard JDBC Wrapper.unwrap() implementation: if isWrapperFor(iface) says this object does not implement or wrap the requested interface, the SQLException 'No wrapper for <iface>' is thrown. It means the caller requested a type this PrestoResultSetMetaData cannot expose.","triggerScenarios":"Calling metaData.unwrap(SomeClass.class) where SomeClass is not PrestoResultSetMetaData, not an interface it implements (ResultSetMetaData, Wrapper), and not assignable from the object.","commonSituations":"Unwrapping to a vendor-specific interface of a different driver (e.g. casting to another JDBC product's class); reflection-based framework code assuming a specific wrapper type; copy-pasted unwrap calls targeting the wrong driver's API class.","solutions":["Unwrap only to interfaces PrestoResultSetMetaData actually implements (e.g. java.sql.ResultSetMetaData) or the concrete PrestoResultSetMetaData class","Guard with isWrapperFor(iface) before calling unwrap","Use the JDBC-standard interfaces instead of vendor-specific types"],"exampleFix":"// before\nMyVendorMeta m = meta.unwrap(MyVendorMeta.class); // throws\n// after\nif (meta.isWrapperFor(PrestoResultSetMetaData.class)) {\n    PrestoResultSetMetaData m = meta.unwrap(PrestoResultSetMetaData.class);\n}","handlingStrategy":"validation","validationCode":"if (!meta.isWrapperFor(TargetType.class)) {\n    throw new IllegalStateException(\"Metadata does not wrap \" + TargetType.class.getName());\n}","typeGuard":"boolean usable = iface != null && (iface.isInstance(meta));","tryCatchPattern":"try {\n    T t = meta.unwrap(TargetType.class);\n} catch (SQLException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"No wrapper for\")) {\n        // use the standard java.sql.ResultSetMetaData interface instead\n    } else { throw e; }\n}","preventionTips":["Only unwrap to interfaces the object actually implements","Always call isWrapperFor before unwrap","Avoid vendor-specific wrapper types when writing driver-agnostic code"],"tags":["jdbc","metadata","unwrap"],"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-12T02:17:10.037Z"}