zy-kkk commented on code in PR #43059:
URL: https://github.com/apache/doris/pull/43059#discussion_r1825546918


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java:
##########
@@ -294,30 +296,33 @@ private boolean isConvertDatetimeToNull(JdbcClientConfig 
jdbcClientConfig) {
      * get all columns like DatabaseMetaData.getColumns in mysql-jdbc-connector
      */
     private Map<String, String> getColumnsDataTypeUseQuery(String 
remoteDbName, String remoteTableName) {
-        Connection conn = getConnection();
+        Connection conn = null;
+        Statement stmt = null;
         ResultSet resultSet = null;
-        Map<String, String> fieldtoType = Maps.newHashMap();
+        Map<String, String> fieldToType = Maps.newHashMap();
 
         StringBuilder queryBuf = new StringBuilder("SHOW FULL COLUMNS FROM ");
         queryBuf.append(remoteTableName);
         queryBuf.append(" FROM ");
         queryBuf.append(remoteDbName);
-        try (Statement stmt = conn.createStatement()) {
+        try {
+            conn = getConnection();
+            stmt = conn.createStatement();
             resultSet = stmt.executeQuery(queryBuf.toString());
             while (resultSet.next()) {
                 // get column name
                 String fieldName = resultSet.getString("Field");
                 // get original type name
                 String typeName = resultSet.getString("Type");
-                fieldtoType.put(fieldName, typeName);
+                fieldToType.put(fieldName, typeName);
             }
         } catch (SQLException e) {
             throw new JdbcClientException("failed to get jdbc columns info for 
remote table `%s.%s`: %s",
                     remoteDbName, remoteTableName, 
Util.getRootCauseMessage(e));
         } finally {
-            close(resultSet, conn);
+            close(resultSet, stmt, conn);
         }
-        return fieldtoType;
+        return fieldToType;

Review Comment:
   I checked whether the object is null in the close() method, and because some 
drivers do not implement AutoCloseable, we need to close it manually.



-- 
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-unsubscr...@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to