{"record":{"id":"17aee1810e8e5e7f","repo":"brettwooldridge/HikariCP","slug":"wrapped-resultset-is-not-an-instance-of","errorCode":null,"errorMessage":"Wrapped ResultSet is not an instance of {}","messagePattern":"Wrapped ResultSet is not an instance of (.+?)","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/zaxxer/hikari/pool/ProxyResultSet.java","lineNumber":108,"sourceCode":"   @Override\n   public final boolean isWrapperFor(Class<?> iface) throws SQLException\n   {\n      return iface.isInstance(delegate) || (delegate != null && delegate.isWrapperFor(iface));\n   }\n\n   /** {@inheritDoc} */\n   @Override\n   @SuppressWarnings(\"unchecked\")\n   public final <T> T unwrap(Class<T> iface) throws SQLException\n   {\n      if (iface.isInstance(delegate)) {\n         return (T) delegate;\n      }\n      else if (delegate != null) {\n          return delegate.unwrap(iface);\n      }\n\n      throw new SQLException(\"Wrapped ResultSet is not an instance of \" + iface);\n   }\n}\n","sourceCodeStart":90,"sourceCodeEnd":111,"githubUrl":"https://github.com/brettwooldridge/HikariCP/blob/a4d93f4f85517f90e632b795486d7102e933d7ff/src/main/java/com/zaxxer/hikari/pool/ProxyResultSet.java#L90-L111","documentation":"ProxyResultSet.unwrap(iface) throws SQLException when the underlying driver ResultSet does not implement the requested interface and cannot unwrap to it. ResultSets handed out by HikariCP proxies are thin wrappers; unwrap success depends entirely on the delegate's capabilities.","triggerScenarios":"rs.unwrap(VendorResultSet.class) for vendor cursor/array APIs the driver does not expose on ResultSet; using unwrap on closed result sets whose delegate is ClosedConnection-like; wrong interface passed (e.g. a Statement type).","commonSituations":"Vendor streaming/cursor APIs, Oracle ARRAY/STRUCT fetch helpers, tests with fake ResultSets.","solutions":["Check rs.isWrapperFor(iface) before calling unwrap","Prefer standard JDBC APIs (getObject, getArray) over vendor-specific unwrap paths","Cast the vendor object at fetch time (driver returns vendor types from getObject) rather than unwrapping the ResultSet"],"exampleFix":"// before\nOracleResultSet ors = rs.unwrap(OracleResultSet.class);\n\n// after\njava.sql.Array arr = rs.getArray(1); // standard API\n// or guard:\nif (rs.isWrapperFor(OracleResultSet.class)) { ... }","handlingStrategy":"type-guard","validationCode":"if (rs.isWrapperFor(VendorResultSet.class)) { ... }","typeGuard":"boolean canUnwrapRs(ResultSet rs, Class<?> iface) {\n    try { return !rs.isClosed() && rs.isWrapperFor(iface); }\n    catch (SQLException e) { return false; }\n}","tryCatchPattern":"try { v = rs.unwrap(iface); }\ncatch (SQLException e) {\n    if (e.getMessage().contains(\"not an instance of\")) { /* use getObject/getArray standard APIs */ }\n    else throw e;\n}","preventionTips":["Use standard JDBC accessors before vendor unwrap","Guard with isWrapperFor","Do not unwrap closed result sets"],"tags":["hikaricp","jdbc","unwrap","resultset"],"backgroundTag":null,"analyzedSha":"a4d93f4f85517f90e632b795486d7102e933d7ff","analyzedAt":"2026-08-14T12:11:37.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}