SonarSource/sonarqube · error · java.lang.IllegalStateException
Unsupported database dialect:
Error message
Unsupported database dialect:
What it means
CreateDashboardsTable (v202605) adds CREATED_AT/UPDATED_AT timestamp defaults with per-dialect ALTER TABLE templates (H2/PostgreSQL, MsSql ADD CONSTRAINT, Oracle MODIFY). Unsupported dialect ids throw IllegalStateException "Unsupported database dialect: <id>" in addTimestampDefaults, called from the migration's execute.
Source
Thrown at server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v202605/CreateDashboardsTable.java:97
.setTable(tableName)
.setName(DASHBOARDS_NAME_RESOURCE_IDX)
.addColumn(NAME)
.addColumn(RESOURCE_TYPE)
.addColumn(RESOURCE_ID)
.build());
}
private void addTimestampDefaults(Context context, String tableName) {
switch (getDialect().getId()) {
case H2.ID, PostgreSql.ID -> context.execute(
ALTER_COLUMN_DEFAULT_TEMPLATE.formatted(tableName, CREATED_AT),
ALTER_COLUMN_DEFAULT_TEMPLATE.formatted(tableName, UPDATED_AT));
case MsSql.ID -> context.execute(
ADD_DEFAULT_CONSTRAINT_TEMPLATE.formatted(tableName, CREATED_AT_DEFAULT_CONSTRAINT, CREATED_AT),
ADD_DEFAULT_CONSTRAINT_TEMPLATE.formatted(tableName, UPDATED_AT_DEFAULT_CONSTRAINT, UPDATED_AT));
case Oracle.ID -> context.execute(
MODIFY_COLUMNS_DEFAULT_TEMPLATE.formatted(tableName, CREATED_AT, UPDATED_AT));
default -> throw new IllegalStateException("Unsupported database dialect: " + getDialect().getId());
}
}
}
View on GitHub (pinned to 184c821202)
Solutions
- Run this SonarQube version only on a supported database (PostgreSQL, MS SQL, Oracle; H2 for eval).
- If a new dialect must work, add a case with the correct ALTER TABLE ... SET DEFAULT syntax and update all DEFAULT-constraint constants.
- Verify sonar.jdbc.dialect auto-detection isn't being overridden by a wrong explicit value.
Example fix
// before
default -> throw new IllegalStateException("Unsupported database dialect: " + getDialect().getId());
// after
case MySql.ID -> context.execute(ALTER_COLUMN_DEFAULT_TEMPLATE.formatted(tableName, CREATED_AT));
default -> throw new IllegalStateException("Unsupported database dialect: " + getDialect().getId()); Defensive patterns
Strategy: validation
Validate before calling
String id = getDialect().getId();
if (!Set.of(H2.ID, PostgreSql.ID, MsSql.ID, Oracle.ID).contains(id)) {
throw new IllegalArgumentException("Timestamp defaults unsupported for " + id);
} Type guard
boolean supportsTimestampDefaults(Dialect d) { return Set.of(H2.ID, PostgreSql.ID, MsSql.ID, Oracle.ID).contains(d.getId()); } Try / catch
try {
migration.execute(context);
} catch (IllegalStateException e) {
LOG.error("Dashboards table migration failed: {}", e.getMessage());
throw e;
} Prevention
- Set explicit DEFAULT-constraint names per engine (MsSql named constraints) to keep drop/re-add idempotent.
- Don't upgrade SonarQube before confirming the target DB engine is supported for the new version.
- Keep a checklist of per-dialect templates when adding new migration steps.
When it happens
Trigger: Executing the v202605.0 CreateDashboardsTable migration against a Dialect id not in the supported set (h2/postgresql, mssql, oracle).
Common situations: Running a bleeding-edge SonarQube build against an unsupported or experimental database; custom Dialect plugin; misconfigured dialect property.
Related errors
- Unsupported DB:
- Unsupported dialect for drop of constraint:
- Unsupported database '%s'
- Unsupported dialect id
- Unsupported dialect id
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/bb3a15a6d505c0aa.
Report an issue: GitHub.