jeecgboot/JeecgBoot · error · JeecgBootException
数据库驱动类名不能为空
Error message
数据库驱动类名不能为空
What it means
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.
Source
Thrown at jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/security/JdbcSecurityUtil.java:126
String lowerUrl = jdbcUrl.toLowerCase();
for (String unsafeParam : UNSAFE_PARAMS) {
if (lowerUrl.contains(unsafeParam)) {
throw new JeecgBootException("连接地址有安全风险,包含不安全参数【" + unsafeParam + "】");
}
}
}
/**
* 校验驱动类名是否在白名单中
*
* @param driverClassName JDBC 驱动类名
* @throws JeecgBootException 驱动不在白名单时抛出
*/
public static void validateDriver(String driverClassName) {
if (oConvertUtils.isEmpty(driverClassName)) {
throw new JeecgBootException("数据库驱动类名不能为空");
}
for (String allowed : ALLOWED_DRIVERS) {
if (allowed.equals(driverClassName)) {
return;
}
}
throw new JeecgBootException("不支持的数据库驱动【" + driverClassName + "】,如需支持请联系管理员");
}
}View on GitHub (pinned to 96fb33f5ec)
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.
Example fix
// before
sysDataSource.setDbDriver(""); // or null
JdbcSecurityUtil.validateDriver(sysDataSource.getDbDriver()); // throws
// after
sysDataSource.setDbDriver("com.mysql.cj.jdbc.Driver");
JdbcSecurityUtil.validateDriver(sysDataSource.getDbDriver()); // passes Defensive patterns
Strategy: validation
Validate before calling
if (oConvertUtils.isEmpty(driverClassName)) {
return Result.error("请选择数据库驱动");
}
JdbcSecurityUtil.validateDriver(driverClassName); Try / catch
try {
JdbcSecurityUtil.validateDriver(driverClassName);
} catch (JeecgBootException e) {
return Result.error(e.getMessage());
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- 不支持的数据库驱动【{driverClassName}】,如需支持请联系管理员
- 数据源URL配置格式不正确!
- 非法URL:主机名为空
- 参数不能为空
- 连接地址有安全风险,包含不安全参数【{unsafeParam}】
AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14).
Data as JSON: /api/errors/d08aae44c4d89205.
Report an issue: GitHub.