whhe commented on code in PR #5712:
URL: https://github.com/apache/seatunnel/pull/5712#discussion_r1374016364


##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-common/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/AbstractJdbcIT.java:
##########
@@ -95,14 +96,38 @@ public abstract class AbstractJdbcIT extends TestSuiteBase 
implements TestResour
 
     abstract GenericContainer<?> initContainer();
 
+    protected URLClassLoader getUrlClassLoader() throws MalformedURLException {
+        if (urlClassLoader == null) {
+            urlClassLoader =
+                    new URLClassLoader(
+                            new URL[] {new URL(driverUrl())},
+                            AbstractJdbcIT.class.getClassLoader());
+            Thread.currentThread().setContextClassLoader(urlClassLoader);
+        }
+        return urlClassLoader;
+    }
+
+    protected Class<?> loadDriverClassFromUrl() {
+        try {
+            return getUrlClassLoader().loadClass(jdbcCase.getDriverClass());
+        } catch (Exception e) {
+            throw new RuntimeException(
+                    "Failed to load driver class: " + 
jdbcCase.getDriverClass(), e);
+        }
+    }
+
+    protected Class<?> loadDriverClass() {
+        try {
+            return Class.forName(jdbcCase.getDriverClass());
+        } catch (Exception e) {
+            throw new RuntimeException(
+                    "Failed to load driver class: " + 
jdbcCase.getDriverClass(), e);
+        }
+    }
+
     protected void initializeJdbcConnection(String jdbcUrl)
-            throws SQLException, ClassNotFoundException, MalformedURLException,
-                    InstantiationException, IllegalAccessException {
-        URLClassLoader urlClassLoader =
-                new URLClassLoader(
-                        new URL[] {new URL(driverUrl())}, 
AbstractJdbcIT.class.getClassLoader());
-        Thread.currentThread().setContextClassLoader(urlClassLoader);
-        Driver driver = (Driver) 
urlClassLoader.loadClass(jdbcCase.getDriverClass()).newInstance();
+            throws SQLException, InstantiationException, 
IllegalAccessException {
+        Driver driver = (Driver) loadDriverClass().newInstance();

Review Comment:
   Before: every time the `initializeJdbcConnection` method is called, it will 
load the driver class from url
   After: most drivers are loaded from local class path, and only gbase driver 
is loaded from url



-- 
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]

Reply via email to