You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2021/12/09 15:04:53 UTC

[GitHub] [dolphinscheduler] Narcasserun commented on a change in pull request #7294: [Fix-7291][datasource] support driverClassName default

Narcasserun commented on a change in pull request #7294:
URL: https://github.com/apache/dolphinscheduler/pull/7294#discussion_r765876401



##########
File path: dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/provider/JdbcDataSourceProvider.java
##########
@@ -80,4 +89,23 @@ public static HikariDataSource createOneSessionJdbcDataSource(BaseConnectionPara
         return dataSource;
     }
 
+    protected static void loaderJdbcDriver(ClassLoader classLoader, BaseConnectionParam properties, DbType dbType) {
+        String drv = StringUtils.isBlank(properties.getDriverClassName()) ? DatasourceUtil.getDatasourceProcessor(dbType).getDatasourceDriver() : properties.getDriverClassName();
+        try {
+            final Class<?> clazz = Class.forName(drv, true, classLoader);
+            final Driver driver = (Driver) clazz.newInstance();
+            if (!driver.acceptsURL(properties.getJdbcUrl())) {
+                logger.warn("Jdbc driver loading error. Driver {} cannot accept url.", drv);
+                throw new RuntimeException("Jdbc driver loading error.");
+            }
+            if (dbType.equals(DbType.MYSQL) && driver.getMajorVersion() >= 8) {
+                properties.setDriverClassName(drv);
+            } else {

Review comment:
       yes




-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org