{"record":{"id":"876a4d18acff43cb","repo":"t8y2/dbx","slug":"selected-dameng-jdbc-driver-does-not-accept-url","errorCode":null,"errorMessage":"Selected Dameng JDBC driver does not accept URL: {url}","messagePattern":"Selected Dameng JDBC driver does not accept URL: (.+?)","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"agents/drivers/dameng/src/main/java/com/dbx/agent/dameng/DamengAgent.java","lineNumber":188,"sourceCode":"        });\n    }\n\n    @Override\n    protected Connection openConnection(ConnectParams params) throws Exception {\n        return withSuppressedStdout(() -> {\n            if (externalDriver == null) {\n                return DriverManager.getConnection(buildUrl(params), params.getUsername(), params.getPassword());\n            }\n            Properties properties = new Properties();\n            if (params.getUsername() != null) {\n                properties.setProperty(\"user\", params.getUsername());\n            }\n            if (params.getPassword() != null) {\n                properties.setProperty(\"password\", params.getPassword());\n            }\n            Connection connection = externalDriver.connect(buildUrl(params), properties);\n            if (connection == null) {\n                throw new SQLException(\"Selected Dameng JDBC driver does not accept URL: \" + buildUrl(params));\n            }\n            return connection;\n        });\n    }\n\n    @Override\n    protected String connectionValidationQuery() {\n        return \"SELECT 1\";\n    }\n\n    @Override\n    public synchronized void disconnect() {\n        super.disconnect();\n        try {\n            closeExternalDriverLoader();\n        } catch (Exception error) {\n            // Best-effort release during teardown.\n        }","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/dameng/src/main/java/com/dbx/agent/dameng/DamengAgent.java#L170-L206","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","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.","Compare buildUrl(params) output against the driver's documented accepted formats; log the built URL to confirm what is actually being passed.","If supporting multiple drivers, loop over registered drivers and pick one whose acceptsURL(url) returns true before calling connect."],"exampleFix":"// before\nConnection connection = externalDriver.connect(buildUrl(params), properties);\nif (connection == null) {\n    throw new SQLException(\"Selected Dameng JDBC driver does not accept URL: \" + buildUrl(params));\n}\n// after\nString url = buildUrl(params);\nif (!externalDriver.acceptsURL(url)) {\n    throw new SQLException(\"Driver \" + externalDriver.getClass().getName() +\n        \" does not accept URL: \" + url +\n        \" (expected jdbc:dm://host:port; check datasource config and driver jar version)\");\n}\nConnection connection = externalDriver.connect(url, properties);","handlingStrategy":"validation","validationCode":"String url = buildUrl(params);\nif (!url.startsWith(\"jdbc:dm:\")) {\n    throw new IllegalArgumentException(\"Not a Dameng JDBC URL: \" + url + \" (expected jdbc:dm://host:port)\");\n}\nif (!externalDriver.acceptsURL(url)) {\n    throw new SQLException(\"Driver \" + externalDriver.getClass().getName() + \" rejects URL: \" + url);\n}","typeGuard":"static boolean damengUrlAccepted(java.sql.Driver driver, String url) {\n    try { return url != null && driver.acceptsURL(url); } catch (SQLException e) { return false; }\n}","tryCatchPattern":"try {\n    Connection conn = damengAgent.connect(params);\n} catch (SQLException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"does not accept URL\")) {\n        throw new ConfigurationException(\"Check Dameng URL scheme (jdbc:dm://host:port) and driver jar version\", e);\n    }\n    throw e;\n}","preventionTips":["Confirm the URL starts with jdbc:dm:// and uses the port/format documented for your DM server version","Ensure the Dameng driver jar (matching your DM version) is on the classpath and is the driver being selected","Log the built URL before connect() to catch config mistakes early","Prefer DriverManager with acceptsURL filtering when multiple drivers are registered"],"tags":["jdbc","dameng","connection-url","driver-mismatch"],"backgroundTag":"jdbc-driver-url-not-accepted","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}