{"record":{"id":"a2d7913620e321bf","repo":"SonarSource/sonarqube","slug":"unsupported-database-s","errorCode":null,"errorMessage":"Unsupported database '%s'","messagePattern":"Unsupported database '(.+?)'","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DbPrimaryKeyConstraintFinder.java","lineNumber":67,"sourceCode":"\n  String getDbVendorSpecificQuery(String tableName) {\n    Dialect dialect = db.getDialect();\n    String constraintQuery;\n    switch (dialect.getId()) {\n      case PostgreSql.ID:\n        constraintQuery = getPostgresSqlConstraintQuery(tableName);\n        break;\n      case MsSql.ID:\n        constraintQuery = getMssqlConstraintQuery(tableName);\n        break;\n      case Oracle.ID:\n        constraintQuery = getOracleConstraintQuery(tableName);\n        break;\n      case H2.ID:\n        constraintQuery = getH2ConstraintQuery(tableName);\n        break;\n      default:\n        throw new IllegalStateException(format(\"Unsupported database '%s'\", dialect.getId()));\n    }\n    return constraintQuery;\n  }\n\n  private Optional<String> executeQuery(String query) throws SQLException {\n    try (Connection connection = db.getDataSource().getConnection();\n      PreparedStatement pstmt = connection\n        .prepareStatement(query);\n      ResultSet rs = pstmt.executeQuery()) {\n      if (rs.next()) {\n        return Optional.ofNullable(rs.getString(1));\n      }\n      return Optional.empty();\n    }\n  }\n\n  private String getPostgresSqlConstraintQuery(String tableName) {\n    try (Connection connection = db.getDataSource().getConnection()) {","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DbPrimaryKeyConstraintFinder.java#L49-L85","documentation":"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.","triggerScenarios":"constraintQuery() invoked with a dialect whose id has no case in the switch (unsupported or custom dialect).","commonSituations":"Running migrations on an unsupported database; custom dialect implementation returning an unexpected id; dialect registry misconfiguration.","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."],"exampleFix":"// before\nDialect dialect = new MyCustomDialect(\"mydb\");\n// after\nDialect dialect = new PostgreSql();","handlingStrategy":"validation","validationCode":"if (!SUPPORTED_DIALECT_IDS.contains(dialect.getId())) { throw new IllegalStateException(\"Unsupported database: \" + dialect.getId()); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run migrations only on supported vendors","Keep dialect detection configuration consistent","Add vendor-specific branches when onboarding a new database"],"tags":["database","dialect","unsupported","primary-key"],"backgroundTag":"unsupported-operation","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}