{"record":{"id":"8508512af6d4e6e2","repo":"apache/druid","slug":"invalid-url-format-for-mariadb-s","errorCode":null,"errorMessage":"Invalid URL format for MariaDB: [%s]","messagePattern":"Invalid URL format for MariaDB: \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/utils/ConnectionUriUtils.java","lineNumber":279,"sourceCode":"    Set<String> keys = Sets.newHashSetWithExpectedSize(properties.size());\n    properties.forEach((k, v) -> keys.add((String) k));\n    return keys;\n  }\n\n  public static Set<String> tryParseMariaDb2xConnectionUri(String connectionUri)\n      throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException,\n             NoSuchFieldException, InstantiationException\n  {\n    // these are a bit more complicated\n    Class<?> urlParserClass = Class.forName(\"org.mariadb.jdbc.UrlParser\");\n    Class<?> optionsClass = Class.forName(\"org.mariadb.jdbc.util.Options\");\n    Method parseUrl = urlParserClass.getMethod(\"parse\", String.class);\n    Method getOptions = urlParserClass.getMethod(\"getOptions\");\n\n    Object urlParser = parseUrl.invoke(null, connectionUri);\n\n    if (urlParser == null) {\n      throw new IAE(\"Invalid URL format for MariaDB: [%s]\", connectionUri);\n    }\n\n    Object options = getOptions.invoke(urlParser);\n    Field nonMappedOptionsField = optionsClass.getField(MARIADB_EXTRAS);\n    Properties properties = (Properties) nonMappedOptionsField.get(options);\n\n    Field[] fields = optionsClass.getDeclaredFields();\n    Set<String> keys = Sets.newHashSetWithExpectedSize(properties.size() + fields.length);\n    properties.forEach((k, v) -> keys.add((String) k));\n\n    Object defaultOptions = optionsClass.getConstructor().newInstance();\n    for (Field field : fields) {\n      if (field.getName().equals(MARIADB_EXTRAS)) {\n        continue;\n      }\n      try {\n        if (!Objects.equal(field.get(options), field.get(defaultOptions))) {\n          keys.add(field.getName());","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/utils/ConnectionUriUtils.java#L261-L297","documentation":"Thrown by ConnectionUriUtils.tryParseMariaDb2xConnectionUri when the MariaDB Connector/J 2.x UrlParser.parse(uri) static method returns null, meaning the 2.x driver considers the URI invalid or not a mariadb URL. The parser runs reflectively so a null result is the only signal of rejection.","triggerScenarios":"Parsing a URI with the MariaDB 2.x parser where the scheme is not jdbc:mariadb:/ or jdbc:mysql:/ in a form 2.x accepts, malformed host/port section, or unsupported parameters that make parse() return null.","commonSituations":"MariaDB driver version downgrades/upgrades (2.x vs 3.x URL rules differ), URIs with unknown or misspelled parameters, dynamically constructed jdbc:mariadb strings with placeholders never substituted.","solutions":["Check the URI matches the MariaDB 2.x format jdbc:(mariadb|mysql)://[host][:port]/[db][?params]","Ensure the correct mariadb-java-client version is deployed for the URL syntax used","Try parsing the URI directly with org.mariadb.jdbc.UrlParser to get more detail","If the URI is valid for 3.x only, either upgrade the driver or use tryParseMariaDb3xConnectionUri"],"exampleFix":"// before\nString uri = \"jdbc:mariadb:localhost:3306/db\"; // missing '//'\n// after\nString uri = \"jdbc:mariadb://localhost:3306/db\";","handlingStrategy":"validation","validationCode":"if (uri == null || !(uri.startsWith(\"jdbc:mariadb://\") || uri.startsWith(\"jdbc:mysql://\"))) {\n  throw new IllegalArgumentException(\"Not a MariaDB 2.x compatible URI: \" + uri);\n}","typeGuard":null,"tryCatchPattern":"try {\n  params = ConnectionUriUtils.tryParseMariaDb2xConnectionUri(uri);\n} catch (IllegalArgumentException e) {\n  log.error(\"MariaDB 2.x parser rejected URI: {}\", uri);\n  throw e;\n}","preventionTips":["Use the 2.x URL grammar: jdbc:mariadb://host:port/db?params","Confirm the driver version (2.x vs 3.x) before choosing the parse path","Validate URIs with org.mariadb.jdbc.UrlParser.parse() in unit tests"],"tags":["jdbc","mariadb","url-parsing"],"backgroundTag":"invalid-url-format","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}