{"record":{"id":"78d592816850c698","repo":"apache/druid","slug":"failed-to-find-the-db-driver","errorCode":null,"errorMessage":"Failed to find the DB Driver","messagePattern":"Failed to find the DB Driver","errorType":"exception","errorClass":"RE","httpStatus":null,"severity":"critical","filePath":"server/src/main/java/org/apache/druid/metadata/BasicDataSourceExt.java","lineNumber":165,"sourceCode":"          // respect the ContextClassLoader\n          // N.B. This cast may cause ClassCastException which is handled below\n          driverToUse = (Driver) driverFromCCL.newInstance();\n          if (!driverToUse.acceptsURL(getUrl())) {\n            throw new SQLException(\"No suitable driver\", \"08001\");\n          }\n        }\n      }\n      catch (Exception t) {\n        String message = \"Cannot create JDBC driver of class '\" +\n                         (getDriverClassName() != null ? getDriverClassName() : \"\") +\n                         \"' for connect URL '\" + getUrl() + \"'\";\n        LOGGER.error(t, message);\n        throw new SQLException(message, t);\n      }\n    }\n\n    if (driverToUse == null) {\n      throw new RE(\"Failed to find the DB Driver\");\n    }\n\n    final Driver finalDriverToUse = driverToUse;\n\n    return () -> {\n      String user = connectorConfig.getUser();\n      if (user != null) {\n        connectionProperties.put(\"user\", user);\n      } else {\n        log(\"DBCP DataSource configured without a 'username'\");\n      }\n\n      // Note: This is the main point of this class where we are getting fresh password before setting up\n      // every new connection.\n      String password = connectorConfig.getPassword();\n      if (password != null) {\n        connectionProperties.put(\"password\", password);\n      } else {","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/metadata/BasicDataSourceExt.java#L147-L183","documentation":"After driver resolution, createConnectionFactory asserts that a Driver was actually obtained; if driverToUse is still null it throws RuntimeException('Failed to find the DB Driver'). This is an internal fallback indicating neither DriverManager resolution nor reflective instantiation produced a usable driver.","triggerScenarios":"createConnectionFactory completing both driver-resolution paths without assigning driverToUse — e.g. no driverClassName configured and DriverManager.getDriver(getUrl()) did not throw but also no driver was captured, or unusual config combinations that bypass both branches.","commonSituations":"Incomplete metadata storage connector config missing both driverClassName and a resolvable URL; misconfigured custom connector config object where getters return null unexpectedly.","solutions":["Configure druid.metadata.storage.connector.driverClassName explicitly so the reflective path resolves the driver","Ensure the JDBC URL is valid and its driver is on the classpath","Inspect connector config construction so getDriverClassName()/getUrl() return real values"],"exampleFix":"// before\ndruid.metadata.storage.connector.connectURI=jdbc:postgresql://localhost:5432/druid\n// (no driverClassName set)\n// after\ndruid.metadata.storage.connector.connectURI=jdbc:postgresql://localhost:5432/druid\ndruid.metadata.storage.connector.driverClassName=org.postgresql.Driver","handlingStrategy":"validation","validationCode":"if (driverClassName == null || driverClassName.isEmpty()) { throw new IllegalArgumentException(\"driverClassName must be configured\"); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always configure driverClassName for the metadata storage connector","Verify both URL and driver resolve before starting the cluster","Unit-test connector config construction in custom deployments"],"tags":["java","jdbc","driver","config"],"backgroundTag":"missing-required-config-field","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"}