wuchong commented on a change in pull request #15104:
URL: https://github.com/apache/flink/pull/15104#discussion_r589155192



##########
File path: 
flink-connectors/flink-connector-jdbc/src/main/java/org/apache/flink/connector/jdbc/internal/connection/SimpleJdbcConnectionProvider.java
##########
@@ -100,7 +100,16 @@ private Driver getDriver() throws SQLException, 
ClassNotFoundException {
 
     @Override
     public Connection getOrEstablishConnection() throws SQLException, 
ClassNotFoundException {
-        if (connection == null) {
+        if (connection != null) {
+            return connection;
+        }
+        if (jdbcOptions.getDriverName() == null) {
+            connection =
+                    DriverManager.getConnection(
+                            jdbcOptions.getDbURL(),
+                            jdbcOptions.getUsername().orElse(null),
+                            jdbcOptions.getPassword().orElse(null));
+        } else {

Review comment:
       What about changing `getDriver()` to `getDriver(String driverName)` and 
check not null in the method? This can avoid `getDriver()` been used 
accidentally.




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

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


Reply via email to