{"record":{"id":"d08aae44c4d89205","repo":"jeecgboot/JeecgBoot","slug":"error-d08aae","errorCode":null,"errorMessage":"数据库驱动类名不能为空","messagePattern":"数据库驱动类名不能为空","errorType":"validation","errorClass":"JeecgBootException","httpStatus":null,"severity":"error","filePath":"jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/security/JdbcSecurityUtil.java","lineNumber":126,"sourceCode":"\n        String lowerUrl = jdbcUrl.toLowerCase();\n\n        for (String unsafeParam : UNSAFE_PARAMS) {\n            if (lowerUrl.contains(unsafeParam)) {\n                throw new JeecgBootException(\"连接地址有安全风险，包含不安全参数【\" + unsafeParam + \"】\");\n            }\n        }\n    }\n\n    /**\n     * 校验驱动类名是否在白名单中\n     *\n     * @param driverClassName JDBC 驱动类名\n     * @throws JeecgBootException 驱动不在白名单时抛出\n     */\n    public static void validateDriver(String driverClassName) {\n        if (oConvertUtils.isEmpty(driverClassName)) {\n            throw new JeecgBootException(\"数据库驱动类名不能为空\");\n        }\n        for (String allowed : ALLOWED_DRIVERS) {\n            if (allowed.equals(driverClassName)) {\n                return;\n            }\n        }\n        throw new JeecgBootException(\"不支持的数据库驱动【\" + driverClassName + \"】，如需支持请联系管理员\");\n    }\n}","sourceCodeStart":108,"sourceCodeEnd":135,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/security/JdbcSecurityUtil.java#L108-L135","documentation":"Thrown by JdbcSecurityUtil.validateDriver() when the driverClassName parameter is null or empty. This is a simple null/empty guard before checking the driver against the ALLOWED_DRIVERS whitelist. Called from DynamicDBUtil and SysDataSourceController when creating or updating a dynamic data source.","triggerScenarios":"Creating a dynamic data source (via SysDataSourceController add/update API or DynamicDBUtil.addDynamicDataSource) with a null or blank dbDriver field; the front-end data source form submits without selecting a driver class.","commonSituations":"Admin saves a data source configuration but leaves the driver class field empty; a migration script or API call omits the dbDriver property; the driver field is conditionally set based on database type but the condition was not met.","solutions":["Provide a valid JDBC driver class name in the dbDriver field (e.g., 'com.mysql.cj.jdbc.Driver' for MySQL 5.7+).","Add front-end validation requiring the driver field before form submission.","Use a database-type-to-driver mapping in the front-end to auto-fill the driver when the DB type is selected."],"exampleFix":"// before\nsysDataSource.setDbDriver(\"\"); // or null\nJdbcSecurityUtil.validateDriver(sysDataSource.getDbDriver()); // throws\n\n// after\nsysDataSource.setDbDriver(\"com.mysql.cj.jdbc.Driver\");\nJdbcSecurityUtil.validateDriver(sysDataSource.getDbDriver()); // passes","handlingStrategy":"validation","validationCode":"if (oConvertUtils.isEmpty(driverClassName)) {\n    return Result.error(\"请选择数据库驱动\");\n}\nJdbcSecurityUtil.validateDriver(driverClassName);","typeGuard":null,"tryCatchPattern":"try {\n    JdbcSecurityUtil.validateDriver(driverClassName);\n} catch (JeecgBootException e) {\n    return Result.error(e.getMessage());\n}","preventionTips":["Require driver class selection in the data source management form.","Use a DB-type-to-driver-class mapping to auto-fill the driver field.","Validate all required fields before submitting data source configurations."],"tags":["jdbc","validation","null","datasource","config"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}