{"record":{"id":"a603be686409b108","repo":"jd-opensource/joyagent-jdgenie","slug":"s-a603be","errorCode":null,"errorMessage":"%s 暂不支持","messagePattern":"%s 暂不支持","errorType":"exception","errorClass":"JdbcBizException","httpStatus":null,"severity":"error","filePath":"genie-backend/src/main/java/com/jd/genie/data/jdbc/connection/JdbcConnectionPoolFactory.java","lineNumber":43,"sourceCode":"\n    public DatasourceWrapper createPooledDatasource(JdbcConnectionConfig connConfig) {\n        JdbcDialect jdbcDialect = JdbcDialectLoader.load(connConfig.getUrl());\n        DatasourceWrapper datasourceWrapper = new DatasourceWrapper();\n        datasourceWrapper.setJdbcDialect(jdbcDialect);\n        JdbcCatalog catalog = JdbcCatalogLoader.load(jdbcDialect.dialectName());\n        datasourceWrapper.setCatalog(catalog);\n        datasourceWrapper.setFreshTime(connConfig.getFreshTimestamp());\n\n        //set jdbc dialect\n        connConfig.setJdbcDialect(jdbcDialect.dialectName());\n        switch (connConfig.getJdbcDialect()) {\n            case MYSQL:\n            case H2:\n            case CLICKHOUSE:\n                datasourceWrapper.setDataSource(createHikariDatasource(connConfig, jdbcDialect));\n                break;\n            default:\n                throw new JdbcBizException(String.format(\"%s 暂不支持\", connConfig.getJdbcDialect()));\n        }\n        return datasourceWrapper;\n    }\n\n    private DataSource createHikariDatasource(JdbcConnectionConfig connConfig, JdbcDialect jdbcDialect) {\n        HikariConfig config = new HikariConfig();\n        config.setPoolName(CONNECTION_POOL_PREFIX + connConfig.getKey());\n        config.setDriverClassName(jdbcDialect.driverName());\n        config.setUsername(connConfig.getUserName());\n        config.setPassword(connConfig.getPassword());\n        config.setJdbcUrl(connConfig.getUrl());\n\n        if (connConfig.getReadOnly() != null) {\n            config.setReadOnly(connConfig.getReadOnly());\n        }\n        if (connConfig.getConnectionTimeout() != null) {\n            config.setConnectionTimeout((connConfig.getConnectionTimeout()));\n        }","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/jd-opensource/joyagent-jdgenie/blob/2417e0b8b636d941ad5fb14c59b20dddfef5375d/genie-backend/src/main/java/com/jd/genie/data/jdbc/connection/JdbcConnectionPoolFactory.java#L25-L61","documentation":"JdbcConnectionPoolFactory.createPooledDatasource builds a pooled datasource per JDBC dialect. MYSQL, H2 and CLICKHOUSE are handled via HikariCP; any other dialect hits the default branch and throws JdbcBizException '<dialect> 暂不支持'. It is an explicit unsupported-database-type guard.","triggerScenarios":"Calling createPooledDatasource with a JdbcConnectionConfig whose jdbcDialect is not MYSQL, H2, or CLICKHOUSE (e.g. POSTGRESQL, ORACLE, or an unknown string).","commonSituations":"Adding a new database type to config without extending the factory, typo in dialect name, or reusing a config from another service that supports more dialects.","solutions":["Set jdbcDialect to one of MYSQL, H2 or CLICKHOUSE in the connection config.","Add a case branch for the new dialect in createPooledDatasource (e.g. create PostgreSQL Hikari datasource).","Check the DialectEnum value actually maps to the intended database.","Validate the dialect value early (e.g. DialectEnum.of) before reaching the factory."],"exampleFix":"// before\nconfig.setJdbcDialect(\"POSTGRESQL\"); // throws 暂不支持\n// after\nconfig.setJdbcDialect(\"MYSQL\"); // supported dialect\n// or extend the factory:\ncase POSTGRESQL: datasourceWrapper.setDataSource(createHikariDatasource(connConfig, jdbcDialect)); break;","handlingStrategy":"validation","validationCode":"// Java: check the dialect is supported before creating a pool\nSet<String> SUPPORTED = Set.of(\"MYSQL\", \"H2\", \"CLICKHOUSE\");\nif (!SUPPORTED.contains(connConfig.getJdbcDialect().toUpperCase())) {\n    throw new IllegalArgumentException(\"unsupported dialect: \" + connConfig.getJdbcDialect());\n}","typeGuard":null,"tryCatchPattern":"try {\n    DatasourceWrapper ds = factory.createPooledDatasource(connConfig);\n} catch (JdbcBizException e) {\n    log.error(\"Unsupported dialect: {}\", connConfig.getJdbcDialect(), e);\n    // surface a config error to the operator\n}","preventionTips":["Whitelist dialects at config-load time with DialectEnum.of.","Extend the factory switch when adding a new database type.","Keep dialect strings in an enum, not free-form config strings.","Add a startup config check that fails fast on unsupported dialects."],"tags":["jdbc","datasource","unsupported"],"backgroundTag":"unsupported-enum-value","analyzedSha":"2417e0b8b636d941ad5fb14c59b20dddfef5375d","analyzedAt":"2026-09-08T11:28:19.414Z","contentChangedAt":"2026-09-08T11:28:19.414Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}