elunez/eladmin · error · RuntimeException

Not supported data type: jdbcUrl={jdbcUrl}

Error message

Not supported data type: jdbcUrl={jdbcUrl}

What it means

Fallback branch in SqlUtils.getDataSource: if DriverManager could not determine a class name (className empty), the code tries DataTypeEnum.urlOf(jdbcUrl) to map the URL prefix to a known driver. A null return means the URL matches none of the supported DataTypeEnum prefixes (mysql, oracle, sqlserver, postgres, h2, etc.), so no driver class can be assigned and the datasource creation aborts.

Source

Thrown at eladmin-system/src/main/java/me/zhengjie/modules/maint/util/SqlUtils.java:60

	 * 获取数据源
	 *
	 * @param jdbcUrl /
	 * @param userName /
	 * @param password /
	 * @return DataSource
	 */
	private static DataSource getDataSource(String jdbcUrl, String userName, String password) {
		DruidDataSource druidDataSource = new DruidDataSource();
		String className;
		try {
			className = DriverManager.getDriver(jdbcUrl.trim()).getClass().getName();
		} catch (SQLException e) {
			throw new RuntimeException("Get class name error: =" + jdbcUrl);
		}
		if (StringUtils.isEmpty(className)) {
			DataTypeEnum dataTypeEnum = DataTypeEnum.urlOf(jdbcUrl);
			if (null == dataTypeEnum) {
				throw new RuntimeException("Not supported data type: jdbcUrl=" + jdbcUrl);
			}
			druidDataSource.setDriverClassName(dataTypeEnum.getDriver());
		} else {
			druidDataSource.setDriverClassName(className);
		}

		// 去掉不安全的参数
		jdbcUrl = sanitizeJdbcUrl(jdbcUrl);

		druidDataSource.setUrl(jdbcUrl);
		druidDataSource.setUsername(userName);
		druidDataSource.setPassword(password);
		// 配置获取连接等待超时的时间
		druidDataSource.setMaxWait(3000);
		// 配置初始化大小、最小、最大
		druidDataSource.setInitialSize(1);
		druidDataSource.setMinIdle(1);
		druidDataSource.setMaxActive(1);

View on GitHub (pinned to 55fbf70595)

Solutions

  1. Use a supported database URL prefix — check me.zhengjie.modules.mnt.database.DataTypeEnum for the accepted values (typically mysql, postgres, oracle, sqlserver, h2).
  2. If you must support another database, extend DataTypeEnum with its url prefix and driver class, and add the driver dependency.
  3. Verify the URL format matches the enum's urlOf matching logic (prefix-based, case-sensitive).

Example fix

// before
String url = "jdbc:mariadb://127.0.0.1:3306/db"; // not in DataTypeEnum -> null
// after
String url = "jdbc:mysql://127.0.0.1:3306/db"; // or add MARIADB("jdbc:mariadb", "org.mariadb.jdbc.Driver") to DataTypeEnum
Defensive patterns

Strategy: validation

Validate before calling

// whitelist-check the URL prefix against the supported enum before use
boolean supported = Arrays.stream(DataTypeEnum.values())
    .anyMatch(e -> jdbcUrl.trim().toLowerCase().startsWith(e.getUrlPrefix().toLowerCase()));
if (!supported) throw new IllegalArgumentException("Unsupported database type: " + jdbcUrl);

Try / catch

try { ... } catch (RuntimeException e) { if (e.getMessage().contains("Not supported data type")) { notify("仅支持 DataTypeEnum 中列出的数据库类型"); return; } throw e; }

Prevention

When it happens

Trigger: Passing a jdbcUrl whose subprotocol is not covered by DataTypeEnum — e.g. 'jdbc:db2://...', 'jdbc:mariadb://...' (if not enumerated), or a URL with a typo in the subprotocol — through the maintenance SQL tooling. Only reached when auto-detection via DriverManager also failed to yield a class name.

Common situations: Trying to use the online database-management module against a database brand eladmin does not enumerate (DB2, MariaDB, SQLite), or misspelling 'jdbc:mysql' as 'jdbc:mysq'. Check the DataTypeEnum source for the exact supported prefix list.

Related errors


AI-assisted analysis of elunez/eladmin@55fbf70595 (2026-08-14). Data as JSON: /api/errors/170736494970ca2e. Report an issue: GitHub.