apache/druid · critical · SQLException

08001

08001

Error message

No suitable driver

What it means

When the driver is instantiated reflectively from the context classloader, BasicDataSourceExt validates it with Driver.acceptsURL(getUrl()) and throws SQLException('No suitable driver', SQLState 08001) if the driver rejects the JDBC URL. The configured URL's scheme does not match any registered/loaded driver.

Source

Thrown at server/src/main/java/org/apache/druid/metadata/BasicDataSourceExt.java:151

        }
        catch (Exception t) {
          String message = "Cannot load JDBC driver class '" +
                           getDriverClassName() + "'";
          LOGGER.error(t, message);
          throw new SQLException(message, t);
        }
      }

      try {
        if (driverFromCCL == null) {
          driverToUse = DriverManager.getDriver(getUrl());
        } else {
          // Usage of DriverManager is not possible, as it does not
          // respect the ContextClassLoader
          // N.B. This cast may cause ClassCastException which is handled below
          driverToUse = (Driver) driverFromCCL.newInstance();
          if (!driverToUse.acceptsURL(getUrl())) {
            throw new SQLException("No suitable driver", "08001");
          }
        }
      }
      catch (Exception t) {
        String message = "Cannot create JDBC driver of class '" +
                         (getDriverClassName() != null ? getDriverClassName() : "") +
                         "' for connect URL '" + getUrl() + "'";
        LOGGER.error(t, message);
        throw new SQLException(message, t);
      }
    }

    if (driverToUse == null) {
      throw new RE("Failed to find the DB Driver");
    }

    final Driver finalDriverToUse = driverToUse;

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Fix the JDBC URL so its scheme matches the configured driver (e.g. jdbc:postgresql://host:5432/db for PostgreSQL)
  2. Verify the driverClassName corresponds to the same database as the URL
  3. Log/inspect the resolved URL for missing or malformed jdbc: prefix

Example fix

// before
druid.metadata.storage.connector.url=jdbc:postgresql//localhost:5432/druid
// after
druid.metadata.storage.connector.url=jdbc:postgresql://localhost:5432/druid
Defensive patterns

Strategy: validation

Validate before calling

if (jdbcUrl == null || !jdbcUrl.startsWith("jdbc:")) { throw new IllegalArgumentException("Invalid JDBC URL: " + jdbcUrl); }

Try / catch

try { dataSource.getConnection(); } catch (SQLException e) { if ("08001".equals(e.getSQLState())) { log.error("JDBC URL rejected by driver; check url scheme matches driverClassName"); } throw e; }

Prevention

When it happens

Trigger: createConnectionFactory where driverFromCCL is instantiated and acceptsURL(getUrl()) returns false — typically a malformed or wrong-protocol JDBC URL (e.g. jdbc:postgresql:// URL with a MySQL driver, missing 'jdbc:' prefix, typo in scheme).

Common situations: Copy-pasted JDBC URL with wrong database type; URL built from config placeholders left empty; using a driver that does not support the URL sub-protocol after a database migration.

Understand the failure class

Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.

Related errors


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