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

jin pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/incubator-hugegraph-toolchain.git


The following commit(s) were added to refs/heads/master by this push:
     new d58c773a refactor(loader): add a useSSL option for mysql (#650)
d58c773a is described below

commit d58c773a97d4b26f18a0e7d074bfd4526ff1e98a
Author: MuleiSY <[email protected]>
AuthorDate: Wed Jan 15 18:51:34 2025 +0800

    refactor(loader): add a useSSL option for mysql (#650)
    
    
    
    ---------
    
    Co-authored-by: imbajin <[email protected]>
---
 .../hugegraph/loader/test/functional/DBUtil.java   | 25 +++++++++-------------
 .../loader/test/functional/JDBCLoadTest.java       |  7 +++---
 2 files changed, 14 insertions(+), 18 deletions(-)

diff --git 
a/hugegraph-loader/src/test/java/org/apache/hugegraph/loader/test/functional/DBUtil.java
 
b/hugegraph-loader/src/test/java/org/apache/hugegraph/loader/test/functional/DBUtil.java
index 58abdc1a..49b41db7 100644
--- 
a/hugegraph-loader/src/test/java/org/apache/hugegraph/loader/test/functional/DBUtil.java
+++ 
b/hugegraph-loader/src/test/java/org/apache/hugegraph/loader/test/functional/DBUtil.java
@@ -17,13 +17,13 @@
 
 package org.apache.hugegraph.loader.test.functional;
 
+import org.apache.hugegraph.loader.exception.LoadException;
+
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.sql.Statement;
 
-import org.apache.hugegraph.loader.exception.LoadException;
-
 public class DBUtil {
 
     private final String driver;
@@ -40,33 +40,28 @@ public class DBUtil {
         this.pass = pass;
     }
 
-    public void connect() {
+    public void connect(boolean useSSL) {
         try {
             Class.forName(this.driver);
-            String url = String.format("%s?%s", this.url, "useSSL=false");
+            String url = String.format("%s?useSSL=%s", this.url, useSSL);
             this.conn = DriverManager.getConnection(url, this.user, this.pass);
         } catch (ClassNotFoundException e) {
-            throw new LoadException("Invalid driver class '%s'",
-                                    e, this.driver);
+            throw new LoadException("Invalid driver class '%s'", e, 
this.driver);
         } catch (SQLException e) {
-            throw new LoadException("Failed to connect database via '%s'",
-                                    e, this.url);
+            throw new LoadException("Failed to connect database via '%s'", e, 
this.url);
         }
     }
 
-    public void connect(String database) {
+    public void connect(String database, boolean useSSL) {
         this.close();
-        String url = String.format("%s/%s?%s", this.url, database,
-                                   "useSSL=false");
+        String url = String.format("%s/%s?useSSL=%s", this.url, database, 
useSSL);
         try {
             Class.forName(this.driver);
             this.conn = DriverManager.getConnection(url, this.user, this.pass);
         } catch (ClassNotFoundException e) {
-            throw new LoadException("Invalid driver class '%s'",
-                                    e, this.driver);
+            throw new LoadException("Invalid driver class '%s'", e, 
this.driver);
         } catch (SQLException e) {
-            throw new LoadException("Failed to connect database via '%s'",
-                                    e, this.url);
+            throw new LoadException("Failed to connect database via '%s'", e, 
this.url);
         }
     }
 
diff --git 
a/hugegraph-loader/src/test/java/org/apache/hugegraph/loader/test/functional/JDBCLoadTest.java
 
b/hugegraph-loader/src/test/java/org/apache/hugegraph/loader/test/functional/JDBCLoadTest.java
index 3a082648..3cd83483 100644
--- 
a/hugegraph-loader/src/test/java/org/apache/hugegraph/loader/test/functional/JDBCLoadTest.java
+++ 
b/hugegraph-loader/src/test/java/org/apache/hugegraph/loader/test/functional/JDBCLoadTest.java
@@ -48,16 +48,17 @@ public class JDBCLoadTest extends LoadTest {
     private static final String PASS = "root";
 
     private static final DBUtil dbUtil = new DBUtil(DRIVER, DB_URL, USER, 
PASS);
+    private static final boolean USE_SSL = false;
 
     @BeforeClass
     public static void setUp() {
         clearServerData();
 
-        dbUtil.connect();
-        // create the database
+        dbUtil.connect(USE_SSL);
+        // create database
         dbUtil.execute(String.format("CREATE DATABASE IF NOT EXISTS `%s`;", 
DATABASE));
         // create tables
-        dbUtil.connect(DATABASE);
+        dbUtil.connect(DATABASE, USE_SSL);
         // vertex person
         dbUtil.execute("CREATE TABLE IF NOT EXISTS `person` (" +
                        "`id` int(10) unsigned NOT NULL," +

Reply via email to