{"record":{"id":"50229c0833346164","repo":"apache/druid","slug":"failed-to-find-mysql-driver-class-please-check-th","errorCode":null,"errorMessage":"Failed to find MySQL driver class. Please check the MySQL connector version 8.2.0 is in the classpath","messagePattern":"Failed to find MySQL driver class\\. Please check the MySQL connector version 8\\.2\\.0 is in the classpath","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/utils/ConnectionUriUtils.java","lineNumber":115,"sourceCode":"   * If the uri does not match any of these schemes, this method will return an empty set if unknown uris are allowed,\n   * or throw an exception if not.\n   */\n  public static Set<String> tryParseJdbcUriParameters(String connectionUri, boolean allowUnknown)\n  {\n    if (connectionUri.startsWith(MYSQL_PREFIX)) {\n      try {\n        return tryParseMySqlConnectionUri(connectionUri);\n      }\n      catch (ClassNotFoundException notFoundMysql) {\n        try {\n          return tryParseMariaDb2xConnectionUri(connectionUri);\n        }\n        catch (ClassNotFoundException notFoundMaria2x) {\n          try {\n            return tryParseMariaDb3xConnectionUri(connectionUri);\n          }\n          catch (ClassNotFoundException notFoundMaria3x) {\n            throw new RuntimeException(\n                \"Failed to find MySQL driver class. Please check the MySQL connector version 8.2.0 is in the classpath\",\n                notFoundMysql\n            );\n          }\n          catch (IllegalArgumentException iaeMaria3x) {\n            throw iaeMaria3x;\n          }\n          catch (Throwable otherMaria3x) {\n            throw new RuntimeException(otherMaria3x);\n          }\n        }\n        catch (IllegalArgumentException iaeMaria2x) {\n          throw iaeMaria2x;\n        }\n        catch (Throwable otherMaria2x) {\n          throw new RuntimeException(otherMaria2x);\n        }\n      }","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/utils/ConnectionUriUtils.java#L97-L133","documentation":"tryParseJdbcUriParameters attempts to parse a jdbc:mysql:... URI using the MySQL Connector/J 8.x driver class reflectively (Class.forName), falling back to MariaDB drivers. If the MySQL driver class is absent AND both MariaDB driver versions are also absent/unresolvable, it rethrows this RuntimeException naming MySQL connector 8.2.0 as the required dependency.","triggerScenarios":"Calling ConnectionUriUtils.tryParseJdbcUriParameters on a jdbc:mysql URI in a runtime that has none of mysql-connector-j 8.x, mariadb 2.x, or mariadb 3.x classes on the classpath.","commonSituations":"Extensions-metadata deployments missing the mysql-metadata-storage extension, slimmed containers where JDBC jars were excluded, or a version bump where the expected driver class names moved between connector versions.","solutions":["Add mysql-connector-j (8.2.0 or compatible) to the classpath / extensions directory.","Alternatively install a MariaDB connector (2.x or 3.x) which the fallback path can use for mysql URIs.","Verify the driver class is loadable: Class.forName(\"com.mysql.cj.jdbc.Driver\") and check the extension is listed in druid.extensions.loadList.","Align connector versions with the Druid version's documented metadata-storage dependencies."],"exampleFix":"// before: running without any MySQL/MariaDB driver jar\n// after: add to extensions dir or pom\n// <dependency>\n//   <groupId>com.mysql</groupId>\n//   <artifactId>mysql-connector-j</artifactId>\n//   <version>8.2.0</version>\n// </dependency>","handlingStrategy":"try-catch","validationCode":"static boolean mysqlDriverPresent() {\n  try {\n    Class.forName(\"com.mysql.cj.jdbc.Driver\");\n    return true;\n  } catch (ClassNotFoundException e) {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  params = ConnectionUriUtils.tryParseJdbcUriParameters(uri, false);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"Failed to find MySQL driver class\")) {\n    log.error(\"MySQL connector missing from classpath; add mysql-connector-j\");\n  }\n  throw e;\n}","preventionTips":["Deploy the mysql-metadata-storage extension or mysql-connector-j jar","Verify extensions.loadList includes the MySQL extension","Smoke-test Class.forName on the driver class at startup","Keep connector versions aligned with the Druid version's docs"],"tags":["jdbc","mysql","classpath","dependency"],"backgroundTag":"missing-dependency","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}