t8y2/dbx · error · SQLException

Selected Dameng JDBC driver does not accept URL: {url}

Error message

Selected Dameng JDBC driver does not accept URL: {url}

What it means

DamengAgent.openConnection() loads the selected Dameng JDBC driver and calls Driver.connect(url, properties). Per the JDBC spec, connect() returns null when the driver does not accept (does not 'understand') the URL. The agent converts that null into a SQLException naming the URL, so a driver/URL mismatch surfaces as a clear error instead of a NullPointerException.

Source

Thrown at agents/drivers/dameng/src/main/java/com/dbx/agent/dameng/DamengAgent.java:188

        });
    }

    @Override
    protected Connection openConnection(ConnectParams params) throws Exception {
        return withSuppressedStdout(() -> {
            if (externalDriver == null) {
                return DriverManager.getConnection(buildUrl(params), params.getUsername(), params.getPassword());
            }
            Properties properties = new Properties();
            if (params.getUsername() != null) {
                properties.setProperty("user", params.getUsername());
            }
            if (params.getPassword() != null) {
                properties.setProperty("password", params.getPassword());
            }
            Connection connection = externalDriver.connect(buildUrl(params), properties);
            if (connection == null) {
                throw new SQLException("Selected Dameng JDBC driver does not accept URL: " + buildUrl(params));
            }
            return connection;
        });
    }

    @Override
    protected String connectionValidationQuery() {
        return "SELECT 1";
    }

    @Override
    public synchronized void disconnect() {
        super.disconnect();
        try {
            closeExternalDriverLoader();
        } catch (Exception error) {
            // Best-effort release during teardown.
        }

View on GitHub (pinned to c0390bff16)

Solutions

  1. Check the URL passed in params: it must be a valid Dameng JDBC URL (typically jdbc:dm://host:port[/schema]); fix typos or wrong scheme in the connection config.
  2. Verify the correct Dameng driver jar (DmDriver, matching your DM server version) is on the classpath and that it is the driver actually being instantiated (externalDriver), not another registered driver.
  3. Compare buildUrl(params) output against the driver's documented accepted formats; log the built URL to confirm what is actually being passed.
  4. If supporting multiple drivers, loop over registered drivers and pick one whose acceptsURL(url) returns true before calling connect.

Example fix

// before
Connection connection = externalDriver.connect(buildUrl(params), properties);
if (connection == null) {
    throw new SQLException("Selected Dameng JDBC driver does not accept URL: " + buildUrl(params));
}
// after
String url = buildUrl(params);
if (!externalDriver.acceptsURL(url)) {
    throw new SQLException("Driver " + externalDriver.getClass().getName() +
        " does not accept URL: " + url +
        " (expected jdbc:dm://host:port; check datasource config and driver jar version)");
}
Connection connection = externalDriver.connect(url, properties);
Defensive patterns

Strategy: validation

Validate before calling

String url = buildUrl(params);
if (!url.startsWith("jdbc:dm:")) {
    throw new IllegalArgumentException("Not a Dameng JDBC URL: " + url + " (expected jdbc:dm://host:port)");
}
if (!externalDriver.acceptsURL(url)) {
    throw new SQLException("Driver " + externalDriver.getClass().getName() + " rejects URL: " + url);
}

Type guard

static boolean damengUrlAccepted(java.sql.Driver driver, String url) {
    try { return url != null && driver.acceptsURL(url); } catch (SQLException e) { return false; }
}

Try / catch

try {
    Connection conn = damengAgent.connect(params);
} catch (SQLException e) {
    if (e.getMessage() != null && e.getMessage().contains("does not accept URL")) {
        throw new ConfigurationException("Check Dameng URL scheme (jdbc:dm://host:port) and driver jar version", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling connect/open when buildUrl(params) produces a URL that the loaded Dameng driver class does not recognize — wrong URL scheme (not jdbc:dm://...), typo'd prefix, a driver jar for a different DM version whose accepted URL formats differ, or the wrong Driver implementation registered/selected.

Common situations: Config mistake where the Dameng URL was copied from another database (e.g. jdbc:oracle:... or jdbc:postgresql:...); missing 'jdbc:dm' prefix or wrong port/format for the DM8 vs DM7 driver; shaded/wrong version of the Dm driver jar on the classpath that rejects the newer URL format.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/876a4d18acff43cb. Report an issue: GitHub.