ruanwenjun commented on issue #17464: URL: https://github.com/apache/dolphinscheduler/issues/17464#issuecomment-3510382310
> [@ruanwenjun](https://github.com/ruanwenjun) DriverManager will invoke all the registered drivers' acceptsURL method to find out if it is the matched driver by the connection Url `jdbc:mysql://localhost:3306/dolphinscheduler` `jdbc:postgresql://localhost:5432/dolphinscheduler` > > This is the driver match method in DriverManger > > public static Driver getDriver(String url) > throws SQLException { > > println("DriverManager.getDriver(\"" + url + "\")"); > > Class<?> callerClass = Reflection.getCallerClass(); > > // Walk through the loaded registeredDrivers attempting to locate someone > // who understands the given URL. > for (DriverInfo aDriver : registeredDrivers) { > // If the caller does not have permission to load the driver then > // skip it. > if(isDriverAllowed(aDriver.driver, callerClass)) { > try { > if(aDriver.driver.acceptsURL(url)) { > // Success! > println("getDriver returning " + aDriver.driver.getClass().getName()); > return (aDriver.driver); > } > > } catch(SQLException sqe) { > // Drop through and try the next driver. > } > } else { > println(" skipping: " + aDriver.driver.getClass().getName()); > } > > } > > println("getDriver: no suitable driver"); > throw new SQLException("No suitable driver", "08001"); > } > So just delete `Class.forName` and let the DriverManager do the driver class loading job will be better. Some URLs may be matched by multiple drivers simultaneously, e.g., hive2 might be matched by hive/kyuubi driver, mysql might be matched by mysql/oceanbase driver? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
