{"record":{"id":"16a5231a3620a663","repo":"t8y2/dbx","slug":"jdbc-driver-rejected-connect-for-url-url","errorCode":null,"errorMessage":"JDBC driver rejected connect for URL '\" + url + \"'","messagePattern":"JDBC driver rejected connect for URL '\" \\+ url \\+ \"'","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java","lineNumber":678,"sourceCode":"        }\n        // Prefer the explicitly registered driver. DriverManager.getConnection only catches\n        // SQLException; Hive/Inceptor drivers may throw UnsupportedOperationException for optional\n        // methods, which aborts connect before the intended driver is reached.\n        sharedConnection = connectWithRegisteredDriver(url, properties);\n        sharedConnectionKey = key;\n        configureOrdinaryAutoCommit(sharedConnection);\n        return sharedConnection;\n    }\n\n    private static Connection connectWithRegisteredDriver(String url, Properties properties) throws SQLException {\n        if (registeredDriver != null) {\n            try {\n                Connection connection = registeredDriver.connect(url, properties);\n                if (connection != null) {\n                    return connection;\n                }\n            } catch (UnsupportedOperationException | AbstractMethodError error) {\n                throw new SQLException(\"JDBC driver rejected connect for URL '\" + url + \"'\", error);\n            }\n        }\n        try {\n            return DriverManager.getConnection(url, properties);\n        } catch (UnsupportedOperationException | AbstractMethodError error) {\n            throw new SQLException(\"JDBC DriverManager rejected connect for URL '\" + url + \"'\", error);\n        }\n    }\n\n    private static String describeThrowable(Throwable error) {\n        if (error == null) {\n            return \"unknown error\";\n        }\n        String message = error.getMessage();\n        if (message != null && !message.isBlank()\n            && !message.equals(error.getClass().getName())\n            && !message.equals(error.getClass().getSimpleName())) {\n            return error.getClass().getName() + \": \" + message.trim();","sourceCodeStart":660,"sourceCodeEnd":696,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java#L660-L696","documentation":"The plugin first tries the explicitly registered driver's Driver.connect(url, properties). If that call fails with UnsupportedOperationException or AbstractMethodError — meaning the driver class is present but its connect() is not really implemented for this URL/protocol — the plugin wraps it in a SQLException with this message. This catches drivers that were registered but do not actually accept the given URL scheme.","triggerScenarios":"Calling openConnection (via handle/conn/genericTableObjectSource) where registeredDriver.connect() throws UnsupportedOperationException or AbstractMethodError — typically a stub driver, a driver whose class was force-registered from a JAR scan but whose URL scheme (jdbc:xyz:) doesn't match, or an ancient/partial driver implementation.","commonSituations":"Registering a generic JAR whose discovered class isn't the real Driver, mixing driver versions (old driver jar that lacks connect logic for new URL formats), or dialect mismatch like using a MySQL URL against a registered PostgreSQL driver shim.","solutions":["Check that the JDBC URL scheme matches the registered driver (e.g. jdbc:postgresql:... with org.postgresql.Driver).","Register/depend on the official, current driver JAR for the target database instead of a repackaged or partial jar.","Update the driver to a recent release; AbstractMethodError indicates binary incompatibility between driver and JDK/JDBC API version.","Note the plugin falls back to DriverManager.getConnection afterwards — check the follow-up error; if this one persists alone, the registered shim itself is broken, so fix driver discovery/registration."],"exampleFix":"// before\nurl = \"jdbc:mysql://host:3306/db\";      // but org.postgresql.Driver registered\n// after\nurl = \"jdbc:postgresql://host:5432/db\"; // matches registered driver","handlingStrategy":"try-catch","validationCode":"// Java: confirm driver accepts the URL scheme before connecting\nstatic boolean driverAccepts(java.sql.Driver d, String url) throws SQLException {\n    try { return d.acceptsURL(url); } catch (Exception e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n    connection = plugin.open(connCfg);\n} catch (java.sql.SQLException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"JDBC driver rejected connect\")) {\n        throw new IllegalStateException(\"URL scheme does not match registered driver: \" + e.getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Match jdbc:<vendor> URL prefixes to the corresponding driver","Use current official drivers to avoid AbstractMethodError from old builds","Call acceptsURL() yourself as a pre-flight check","Keep one driver per database vendor on the classpath"],"tags":["jdbc","driver-compatibility","connection"],"backgroundTag":"jdbc-driver-rejected-url","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"}