{"record":{"id":"dd5cca7a1606076b","repo":"brettwooldridge/HikariCP","slug":"driver-claims-to-not-accept-jdbcurl","errorCode":null,"errorMessage":"Driver {} claims to not accept jdbcUrl, {}","messagePattern":"Driver (.+?) claims to not accept jdbcUrl, (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"src/main/java/com/zaxxer/hikari/util/DriverDataSource.java","lineNumber":116,"sourceCode":"            if (driverClass != null) {\n               try {\n                  driver = (Driver) driverClass.getDeclaredConstructor().newInstance();\n               } catch (Exception e) {\n                  LOGGER.warn(\"Failed to create instance of driver class {}, trying jdbcUrl resolution\", driverClassName, e);\n               }\n            }\n         }\n      }\n\n      final var sanitizedUrl = maskPasswordInJdbcUrl(jdbcUrl);\n\n      try {\n         if (driver == null) {\n            driver = DriverManager.getDriver(jdbcUrl);\n            LOGGER.debug(\"Loaded driver with class name {} for jdbcUrl={}\", driver.getClass().getName(), sanitizedUrl);\n         }\n         else if (!driver.acceptsURL(jdbcUrl)) {\n            throw new RuntimeException(\"Driver \" + driverClassName + \" claims to not accept jdbcUrl, \" + sanitizedUrl);\n         }\n      }\n      catch (SQLException e) {\n         throw new RuntimeException(\"Failed to get driver instance for jdbcUrl=\" + sanitizedUrl, e);\n      }\n   }\n\n   @Override\n   public Connection getConnection() throws SQLException\n   {\n      return driver.connect(jdbcUrl, driverProperties);\n   }\n\n   @Override\n   public Connection getConnection(final String username, final String password) throws SQLException\n   {\n      final var cloned = (Properties) driverProperties.clone();\n      if (username != null) {","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/brettwooldridge/HikariCP/blob/a4d93f4f85517f90e632b795486d7102e933d7ff/src/main/java/com/zaxxer/hikari/util/DriverDataSource.java#L98-L134","documentation":"DriverDataSource constructor verifies that a driver explicitly configured via dataSourceClassName/driverClassName actually accepts the jdbcUrl (driver.acceptsURL). If it returns false, HikariCP throws RuntimeException naming the driver class and (password-masked) URL — the driver and URL do not match.","triggerScenarios":"Setting jdbcUrl to one database family (e.g. jdbc:mysql://) while driverClassName points at another driver (e.g. org.postgresql.Driver); a driver whose acceptsURL is strict about URL syntax/extra properties; wrong/typo'd jdbc: subprotocol.","commonSituations":"Copy-pasted configs across environments, MySQL vs MariaDB driver mixups (jdbc:mariadb:// with com.mysql.cj.jdbc.Driver), custom sharding proxies whose acceptsURL differs by version.","solutions":["Align driverClassName with the jdbcUrl family (e.g. org.mariadb.jdbc.Driver with jdbc:mariadb://)","Drop driverClassName entirely and let DriverManager auto-detect from the URL (HikariCP resolves it via jdbcUrl)","Fix typos in the jdbc:subprotocol and verify the URL against the driver docs","Upgrade the driver if its acceptsURL is known to be buggy for your URL form"],"exampleFix":"# before\nspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\nspring.datasource.url=jdbc:mariadb://db:3306/app\n\n# after\ndriver-class-name=org.mariadb.jdbc.Driver\nurl=jdbc:mariadb://db:3306/app","handlingStrategy":"validation","validationCode":"// sanity-check before pool creation\nDriver d = DriverManager.getDriver(jdbcUrl);\nif (explicitDriver != null && !explicitDriver.acceptsURL(jdbcUrl)) {\n    throw new IllegalStateException(\"driver/url mismatch\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep driverClassName and jdbcUrl family aligned","Omit driverClassName and rely on URL auto-detection","Add a config validation step at startup"],"tags":["hikaricp","jdbc","driver","configuration","url"],"backgroundTag":null,"analyzedSha":"a4d93f4f85517f90e632b795486d7102e933d7ff","analyzedAt":"2026-08-14T12:11:37.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}