{"record":{"id":"ce03a59bfa18cd37","repo":"t8y2/dbx","slug":"no-jdbc-driver-was-discovered-enter-the-driver-cl","errorCode":null,"errorMessage":"No JDBC driver was discovered. Enter the driver class name for this JAR.","messagePattern":"No JDBC driver was discovered\\. Enter the driver class name for this JAR\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java","lineNumber":620,"sourceCode":"            Driver driver = (Driver) constructor.newInstance();\n            registeredDriver = new DriverShim(driver);\n            DriverManager.registerDriver(registeredDriver);\n            registeredDriverKey = driverKey;\n            return;\n        }\n\n        boolean loaded = false;\n        Driver first = null;\n        for (Driver driver : ServiceLoader.load(Driver.class, loader)) {\n            Driver shim = new DriverShim(driver);\n            if (first == null) {\n                first = shim;\n            }\n            DriverManager.registerDriver(shim);\n            loaded = true;\n        }\n        if (!loaded && !urls.isEmpty()) {\n            throw new IllegalArgumentException(\"No JDBC driver was discovered. Enter the driver class name for this JAR.\");\n        }\n        registeredDriver = first;\n        registeredDriverKey = driverKey;\n    }\n\n    private static Connection openConnection(JsonNode connection) throws SQLException {\n        String url = jdbcUrl(connection);\n        if (url == null) {\n            throw new IllegalArgumentException(\"JDBC URL is required.\");\n        }\n        String key = connectionKey(connection);\n        if (sharedConnection != null && key.equals(sharedConnectionKey) && !isConnectionClosed(sharedConnection)) {\n            configureOrdinaryAutoCommit(sharedConnection);\n            return sharedConnection;\n        }\n        closeSharedConnection();\n\n        JdbcUrlCredentials urlCredentials = extractJdbcUrlCredentials(url);","sourceCodeStart":602,"sourceCodeEnd":638,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java#L602-L638","documentation":"Thrown by registerDrivers in DbxJdbcPlugin after scanning a supplied JAR for JDBC driver classes: no class implementing java.sql.Driver was found or loadable, so the plugin cannot register anything. The plugin parses JARs, inspects META-INF/services/java.sql.Driver and candidate classes, and wraps them in a shim; if `loaded` stays false while JAR URLs exist, it fails fast with this IllegalArgumentException instead of failing later at connect time.","triggerScenarios":"Calling the plugin's driver-registration flow (via handleLine) with a JAR path that contains no JDBC Driver implementation, a shaded/obfuscated driver whose services file was stripped, or a JAR whose driver class fails to load/instantiate (missing dependencies, wrong Java bytecode version).","commonSituations":"Pointing at the wrong JAR (e.g. a driver's non-driver companion jar), fat-jar repackaging that dropped META-INF/services entries, a driver compiled for a newer JDK than the runtime, or a JAR URL typo (file not found produces no discoverable driver).","solutions":["Verify the JAR is the actual JDBC driver artifact (e.g. postgresql-42.x.jar, ojdbc11.jar) and the file path/URL is correct and readable.","Open the JAR and check META-INF/services/java.sql.Driver exists listing the driver class; if missing, add the services entry or use the vendor's official driver JAR.","Since the message says to enter the driver class name, supply the fully-qualified driver class explicitly (e.g. org.postgresql.Driver) via the plugin's driver-class option.","Run on a JDK version compatible with the driver's class-file version and ensure all of the driver's dependency JARs are on the classpath."],"exampleFix":"// before\njarPath = \"/libs/hikariCP.jar\";            // connection pool, not a driver\nregisterDrivers(List.of(jarPath), null);\n// after\njarPath = \"/libs/postgresql-42.7.3.jar\";    // actual driver jar\nregisterDrivers(List.of(jarPath), \"org.postgresql.Driver\"); // explicit class","handlingStrategy":"validation","validationCode":"// Java: verify jar is a driver jar before registering\nboolean isDriverJar(Path jar) throws IOException {\n    try (var zf = new java.util.zip.ZipFile(jar.toFile())) {\n        return zf.getEntry(\"META-INF/services/java.sql.Driver\") != null;\n    }\n}\nif (!isDriverJar(Path.of(jarPath))) throw new IllegalStateException(jarPath + \" has no java.sql.Driver service entry\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only ship official vendor driver JARs, not repackaged/shaded copies","Check META-INF/services/java.sql.Driver exists in every driver jar you deploy","Provide the driver class name explicitly when JAR discovery is ambiguous","Keep JDK version compatible with the driver's target Java version"],"tags":["jdbc","driver-loading","classpath"],"backgroundTag":"jdbc-driver-not-found","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}