This is an automated email from the ASF dual-hosted git repository.

benjobs pushed a commit to branch conf
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


The following commit(s) were added to refs/heads/conf by this push:
     new 21fa1ab96 [Improve] spring.datasource.driver-class-name improvements
21fa1ab96 is described below

commit 21fa1ab96e6eacdb361dc8612db9cc21c051a6c3
Author: benjobs <[email protected]>
AuthorDate: Sat Mar 30 23:35:26 2024 +0800

    [Improve] spring.datasource.driver-class-name improvements
---
 .../streampark/console/base/config/SpringProperties.java   | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/config/SpringProperties.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/config/SpringProperties.java
index b0079ab0e..8f53f02eb 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/config/SpringProperties.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/config/SpringProperties.java
@@ -58,7 +58,19 @@ public class SpringProperties {
     }
     switch (dialect.toLowerCase()) {
       case "mysql":
-        springConfig.put("spring.datasource.driver-class-name", 
"com.mysql.cj.jdbc.Driver");
+        try {
+          Class.forName("com.mysql.cj.jdbc.Driver");
+          springConfig.put("spring.datasource.driver-class-name", 
"com.mysql.cj.jdbc.Driver");
+        } catch (ClassNotFoundException e) {
+          try {
+            Class.forName("com.mysql.jdbc.Driver");
+            springConfig.put("spring.datasource.driver-class-name", 
"com.mysql.jdbc.Driver");
+          } catch (ClassNotFoundException e1) {
+            throw new ExceptionInInitializerError(
+                "datasource.dialect is mysql, \"com.mysql.cj.jdbc.Driver\" and 
\"com.mysql.jdbc.Driver\" classes not found, please check the MySQL driver 
exists in the $streampark/lib,\n"
+                    + "Notice: The Mysql jdbc driver is incompatible with the 
Apache 2.0 license, You need to download the mysql jdbc driver jar and put it 
in $streampark/lib.");
+          }
+        }
         break;
       case "pgsql":
         springConfig.put("spring.datasource.driver-class-name", 
"org.postgresql.Driver");

Reply via email to