SonarSource/sonarqube · error · java.lang.IllegalStateException
Unsupported database '%s'
Error message
Unsupported database '%s'
What it means
Generic guard in DropColumnsBuilder.build(): the SQL builder only knows how to generate DROP COLUMN statements for the PostgreSQL, MsSql, Oracle and H2 dialects; any other configured database id reaches the switch default and aborts the migration with this error. The input at fault is the database dialect of the SonarQube instance being migrated, which is unsupported for this schema-change operation.
Source
Thrown at server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropColumnsBuilder.java:66
this.tableName = tableName;
this.dialect = dialect;
this.columns = columns;
}
public List<String> build() {
switch (dialect.getId()) {
case PostgreSql.ID:
StringBuilder sql = new StringBuilder().append(ALTER_TABLE).append(tableName).append(" ");
dropColumns(sql, "DROP COLUMN ", columns);
return Collections.singletonList(sql.toString());
case MsSql.ID:
return Collections.singletonList(getMsSQLStatement(columns));
case Oracle.ID:
return Collections.singletonList(getOracleStatement());
case H2.ID:
return Arrays.stream(columns).map(this::getMsSQLStatement).toList();
default:
throw new IllegalStateException(String.format("Unsupported database '%s'", dialect.getId()));
}
}
private String getOracleStatement() {
StringBuilder sql = new StringBuilder().append(ALTER_TABLE).append(tableName).append(" ");
sql.append("SET UNUSED (");
dropColumns(sql, "", columns);
sql.append(")");
return sql.toString();
}
private String getMsSQLStatement(String... columnNames) {
StringBuilder sql = new StringBuilder().append(ALTER_TABLE).append(tableName).append(" ");
sql.append("DROP COLUMN ");
dropColumns(sql, "", columnNames);
return sql.toString();
}
View on GitHub (pinned to 184c821202)
Solutions
- Run migrations against a supported database (PostgreSQL, MySQL, MsSql, Oracle, H2).
- Fix the dialect id configuration.
- Add a case for the new dialect in DropColumnsBuilder if it must be supported.
Example fix
// before
case MyDialect.ID: // missing in switch -> default throws
// after
switch (dialect.getId()) {
case PostgreSql.ID: ... case H2.ID: ... // add explicit supported cases
} Defensive patterns
Strategy: validation
Validate before calling
if (!Set.of(PostgreSql.ID, MySql.ID, MsSql.ID, Oracle.ID, H2.ID).contains(dialect.getId())) { throw new IllegalStateException("unsupported dialect"); } Prevention
- Pre-check dialect id before any drop/add column builder usage
- Keep all SQL builders' dialect switches in sync
- Log the detected dialect during startup
When it happens
Trigger: Building a drop-columns migration with an unsupported/unknown dialect id.
Common situations: Unsupported database in sonar.jdbc dialect detection; custom dialect added to the app but not to DropColumnsBuilder; stale builder code after adding a new dialect.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Unknown dialect '%s'
- Unsupported dialect id
- Unknown dialect '%s'
- Unsupported dialect id
- Unknown dialect '%s'
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/97ac5174d107c40a.
Report an issue: GitHub.