{"record":{"id":"0b2e1e574e2eb823","repo":"alibaba/spring-ai-alibaba","slug":"unwrap-is-not-supported","errorCode":null,"errorMessage":"unwrap is not supported","messagePattern":"unwrap is not supported","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/DatabaseStore.java","lineNumber":295,"sourceCode":"         * @return JDBC connection\n         * @throws SQLException if connection opening fails\n         */\n        @Override\n        public Connection getConnection(String username, String password) throws SQLException {\n            return DriverManager.getConnection(jdbcUrl, username, password);\n        }\n\n        /**\n         * Unwrap to vendor-specific interface.\n         *\n         * @param iface target interface\n         * @return wrapped interface\n         * @param <T> generic target type\n         * @throws SQLException if unsupported\n         */\n        @Override\n        public <T> T unwrap(Class<T> iface) throws SQLException {\n            throw new SQLFeatureNotSupportedException(\"unwrap is not supported\");\n        }\n\n        /**\n         * Check if wrapper can provide target interface.\n         *\n         * @param iface target interface\n         * @return false because unwrap is not supported\n         * @param <T> generic target type\n         * @throws SQLException never thrown in this implementation\n         */\n        @Override\n        public boolean isWrapperFor(Class<?> iface) throws SQLException {\n            return false;\n        }\n\n        /**\n         * Return writer used for logging.\n         *","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/DatabaseStore.java#L277-L313","documentation":"SimpleJdbcDataSource implements the JDBC Wrapper interface but does not support unwrap(); any call throws SQLFeatureNotSupportedException with this message. The minimal DataSource wrapper exposes only basic connection acquisition.","triggerScenarios":"Calling dataSource.unwrap(SomeInterface.class) or isWrapperFor-dependent tooling (connection pools, monitoring agents, ORM internals) on the DatabaseStore's internal DataSource.","commonSituations":"Framework instrumentation (e.g. Seata, Druid filters, Flyway internals) attempting to unwrap the native vendor DataSource; code written for pooled DataSource instances reused with this simple wrapper.","solutions":["Pass a real javax.sql.DataSource (e.g. HikariDataSource) to DatabaseStore instead of relying on the built-in SimpleJdbcDataSource if your tooling requires unwrap","Remove/branch around unwrap() calls when using DatabaseStore's simple DataSource","Check instanceof / isWrapperFor before calling unwrap"],"exampleFix":"// before\nConnection c = store.getDataSource().unwrap(org.postgresql.ds.PGPoolingDataSource.class).getConnection();\n// after\ntry (Connection c = store.getDataSource().getConnection()) { /* use connection */ }","handlingStrategy":"try-catch","validationCode":"if (needsUnwrap) { throw new IllegalStateException(\"DatabaseStore's simple DataSource does not support unwrap; supply your own pooled DataSource\"); }","typeGuard":null,"tryCatchPattern":"try { T native = ds.unwrap(T.class); } catch (SQLException e) { log.warn(\"unwrap unsupported by DatabaseStore DataSource; use getConnection() instead\"); }","preventionTips":["Treat DatabaseStore's DataSource as opaque; only call getConnection()","Inject an external pooled DataSource (HikariCP) when framework tooling needs unwrap","Avoid wrapping monitoring/proxy code around SimpleJdbcDataSource"],"tags":["jdbc","unsupported-operation","database"],"backgroundTag":"method-not-implemented","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}