apache/druid · error · IllegalArgumentException

Invalid URL format for MariaDB: [%s]

Error message

Invalid URL format for MariaDB: [%s]

What it means

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.

Source

Thrown at processing/src/main/java/org/apache/druid/utils/ConnectionUriUtils.java:279

    Set<String> keys = Sets.newHashSetWithExpectedSize(properties.size());
    properties.forEach((k, v) -> keys.add((String) k));
    return keys;
  }

  public static Set<String> tryParseMariaDb2xConnectionUri(String connectionUri)
      throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException,
             NoSuchFieldException, InstantiationException
  {
    // these are a bit more complicated
    Class<?> urlParserClass = Class.forName("org.mariadb.jdbc.UrlParser");
    Class<?> optionsClass = Class.forName("org.mariadb.jdbc.util.Options");
    Method parseUrl = urlParserClass.getMethod("parse", String.class);
    Method getOptions = urlParserClass.getMethod("getOptions");

    Object urlParser = parseUrl.invoke(null, connectionUri);

    if (urlParser == null) {
      throw new IAE("Invalid URL format for MariaDB: [%s]", connectionUri);
    }

    Object options = getOptions.invoke(urlParser);
    Field nonMappedOptionsField = optionsClass.getField(MARIADB_EXTRAS);
    Properties properties = (Properties) nonMappedOptionsField.get(options);

    Field[] fields = optionsClass.getDeclaredFields();
    Set<String> keys = Sets.newHashSetWithExpectedSize(properties.size() + fields.length);
    properties.forEach((k, v) -> keys.add((String) k));

    Object defaultOptions = optionsClass.getConstructor().newInstance();
    for (Field field : fields) {
      if (field.getName().equals(MARIADB_EXTRAS)) {
        continue;
      }
      try {
        if (!Objects.equal(field.get(options), field.get(defaultOptions))) {
          keys.add(field.getName());

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Check the URI matches the MariaDB 2.x format jdbc:(mariadb|mysql)://[host][:port]/[db][?params]
  2. Ensure the correct mariadb-java-client version is deployed for the URL syntax used
  3. Try parsing the URI directly with org.mariadb.jdbc.UrlParser to get more detail
  4. If the URI is valid for 3.x only, either upgrade the driver or use tryParseMariaDb3xConnectionUri

Example fix

// before
String uri = "jdbc:mariadb:localhost:3306/db"; // missing '//'
// after
String uri = "jdbc:mariadb://localhost:3306/db";
Defensive patterns

Strategy: validation

Validate before calling

if (uri == null || !(uri.startsWith("jdbc:mariadb://") || uri.startsWith("jdbc:mysql://"))) {
  throw new IllegalArgumentException("Not a MariaDB 2.x compatible URI: " + uri);
}

Try / catch

try {
  params = ConnectionUriUtils.tryParseMariaDb2xConnectionUri(uri);
} catch (IllegalArgumentException e) {
  log.error("MariaDB 2.x parser rejected URI: {}", uri);
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/8508512af6d4e6e2. Report an issue: GitHub.