baomidou/mybatis-plus · error · RuntimeException
Unsupported database type: {}
Error message
Unsupported database type: {} What it means
DdlHelper.newDdlGenerator (the private factory shown) maps the DbType parsed from a JDBC URL to a DDL generator: MySQL family, Oracle family, SQLite, PostgreSQL family. Any other DbType falls through to RuntimeException('Unsupported database type: <jdbcUrl>'). It means you invoked the DDL/dataset-component (e.g. the simple data-script runner) against a database for which no DDL generator ships.
Source
Thrown at mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/ddl/DdlHelper.java:262
}
protected static IDdlGenerator getDdlGenerator(String jdbcUrl) throws RuntimeException {
DbType dbType = JdbcUtils.getDbType(jdbcUrl);
// mysql same type
if (dbType.mysqlSameType()) {
return MysqlDdlGenerator.newInstance();
}
// oracle same type
else if (dbType.oracleSameType()) {
return OracleDdlGenerator.newInstance();
} else if (DbType.SQLITE == dbType) {
return SQLiteDdlGenerator.newInstance();
}
// postgresql same type
else if (dbType.postgresqlSameType()) {
return PostgreDdlGenerator.newInstance();
}
throw new RuntimeException("Unsupported database type: " + jdbcUrl);
}
public static String getDatabase(String jdbcUrl) {
String[] urlArr = jdbcUrl.split("://");
if (urlArr.length == 2) {
String[] dataArr = urlArr[1].split("/");
if (dataArr.length > 1) {
return dataArr[1].split("\\?")[0];
}
}
return null;
}
}
View on GitHub (pinned to bf67d90747)
Solutions
- Use one of the supported databases for DDL operations: MySQL-family, Oracle-family, SQLite, or PostgreSQL-family.
- If you must target an unsupported DB, run your DDL scripts through that database's native tooling or plain JDBC ScriptRunner instead of DdlHelper.
- Check the DbType detection of your JDBC URL (DbType.getDbType(url)) to confirm which branch is (not) taken.
- Contribute or extend with a custom DdlGenerator if you depend on this API long-term.
Example fix
// before: H2 test URL -> RuntimeException('Unsupported database type')
String url = "jdbc:h2:mem:test";
try (Connection c = DdlHelper.getSimpleConnection(driver, url, u, p)) { ... }
// after: run DDL over plain JDBC for unsupported DBs
try (Connection c = DriverManager.getConnection(url, u, p);
Statement st = c.createStatement()) {
st.execute("CREATE TABLE t (id BIGINT PRIMARY KEY)");
} Defensive patterns
Strategy: validation
Validate before calling
DbType dbType = DbType.getDbType(jdbcUrl);
boolean ddlSupported = dbType.mysqlSameType() || dbType.oracleSameType()
|| DbType.SQLITE == dbType || dbType.postgresqlSameType();
if (!ddlSupported) throw new UnsupportedOperationException("DDL helper unsupported for " + dbType); Type guard
static boolean supportsDdlHelper(DbType t) {
return t.mysqlSameType() || t.oracleSameType()
|| t.postgresqlSameType() || DbType.SQLITE == t;
} Try / catch
try {
generator = DdlHelper.newDdlGenerator(driver, url, u, p);
} catch (RuntimeException e) {
if (String.valueOf(e.getMessage()).startsWith("Unsupported database type")) {
// route to plain JDBC script execution instead
} else throw e;
} Prevention
- Check DbType.getDbType(url) against the supported families before invoking DDL APIs.
- Keep DDL execution on MySQL/Oracle/SQLite/PostgreSQL family databases or use native tooling.
When it happens
Trigger: Calling DdlHelper-based APIs (getSimpleConnection, newDdlGenerator — used by the extension's DDL application/dataset module) while connected to H2, SQL Server, DM, Kingbase, ClickHouse, MariaDB-with-unrecognized-URL, or any DbType outside the four supported families.
Common situations: Using the DDL helper during local tests on H2; pointing the tool at SQL Server or a Chinese domestic database (DM/OceanBase/Gauss) that is not in the generator map; a JDBC URL whose DbType detection resolves to something unexpected.
Related errors
- `url` cannot be empty
- 读取[%s]字段出错!
- %s already contains value for %s
- %s does not contain value for %s
- %s is ambiguous in %s (try using the full name including the
AI-assisted analysis of baomidou/mybatis-plus@bf67d90747 (2026-08-14).
Data as JSON: /api/errors/61b4b4ab3d1dc909.
Report an issue: GitHub.