SonarSource/sonarqube · error · java.lang.IllegalStateException
Unsupported database '%s'
Error message
Unsupported database '%s'
What it means
Thrown by DbPrimaryKeyConstraintFinder.getDbVendorSpecificQuery when asked to find the primary-key constraint name on a database dialect it has no query for. The finder builds vendor-specific catalog queries only for supported dialects.
Source
Thrown at server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DbPrimaryKeyConstraintFinder.java:67
String getDbVendorSpecificQuery(String tableName) {
Dialect dialect = db.getDialect();
String constraintQuery;
switch (dialect.getId()) {
case PostgreSql.ID:
constraintQuery = getPostgresSqlConstraintQuery(tableName);
break;
case MsSql.ID:
constraintQuery = getMssqlConstraintQuery(tableName);
break;
case Oracle.ID:
constraintQuery = getOracleConstraintQuery(tableName);
break;
case H2.ID:
constraintQuery = getH2ConstraintQuery(tableName);
break;
default:
throw new IllegalStateException(format("Unsupported database '%s'", dialect.getId()));
}
return constraintQuery;
}
private Optional<String> executeQuery(String query) throws SQLException {
try (Connection connection = db.getDataSource().getConnection();
PreparedStatement pstmt = connection
.prepareStatement(query);
ResultSet rs = pstmt.executeQuery()) {
if (rs.next()) {
return Optional.ofNullable(rs.getString(1));
}
return Optional.empty();
}
}
private String getPostgresSqlConstraintQuery(String tableName) {
try (Connection connection = db.getDataSource().getConnection()) {View on GitHub (pinned to 184c821202)
Solutions
- Use a supported database (PostgreSQL, MySQL, MsSql, Oracle, H2) for the migration run.
- Fix the configured dialect id to a supported value.
- Implement a new vendor-specific branch if the DB must be supported.
Example fix
// before
Dialect dialect = new MyCustomDialect("mydb");
// after
Dialect dialect = new PostgreSql(); Defensive patterns
Strategy: validation
Validate before calling
if (!SUPPORTED_DIALECT_IDS.contains(dialect.getId())) { throw new IllegalStateException("Unsupported database: " + dialect.getId()); } Prevention
- Run migrations only on supported vendors
- Keep dialect detection configuration consistent
- Add vendor-specific branches when onboarding a new database
When it happens
Trigger: constraintQuery() invoked with a dialect whose id has no case in the switch (unsupported or custom dialect).
Common situations: Running migrations on an unsupported database; custom dialect implementation returning an unexpected id; dialect registry misconfiguration.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 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/a2d7913620e321bf.
Report an issue: GitHub.