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

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


The following commit(s) were added to refs/heads/master by this push:
     new 81f6770  Fix sonar by Yanzhe An (#38)
81f6770 is described below

commit 81f6770c0464a73ceba1a9839fcf7e4112a8f126
Author: SolomonAnn <[email protected]>
AuthorDate: Sat Feb 16 21:13:15 2019 +0800

    Fix sonar by Yanzhe An (#38)
    
    * fix sonar:
    
    ** delete redundant quotes
    
    ** remove redundant [ERROR]
---
 .../apache/iotdb/cli/client/AbstractClient.java    |  9 ++-
 .../java/org/apache/iotdb/cli/client/Client.java   | 16 ++--
 .../org/apache/iotdb/cli/client/WinClient.java     |  7 +-
 .../org/apache/iotdb/cli/tool/CsvTestDataGen.java  | 30 +++++---
 .../java/org/apache/iotdb/cli/tool/ExportCsv.java  | 87 ++++++++++++----------
 .../java/org/apache/iotdb/cli/tool/ImportCsv.java  | 63 ++++++++--------
 6 files changed, 123 insertions(+), 89 deletions(-)

diff --git 
a/iotdb-cli/src/main/java/org/apache/iotdb/cli/client/AbstractClient.java 
b/iotdb-cli/src/main/java/org/apache/iotdb/cli/client/AbstractClient.java
index 81aa183..05a21df 100644
--- a/iotdb-cli/src/main/java/org/apache/iotdb/cli/client/AbstractClient.java
+++ b/iotdb-cli/src/main/java/org/apache/iotdb/cli/client/AbstractClient.java
@@ -301,7 +301,7 @@ public abstract class AbstractClient {
     switch (timeFormat) {
       case "long":
       case "number":
-        return timestamp + "";
+        return Long.toString(timestamp);
       case DEFAULT_TIME_FORMAT:
       case "iso8601":
         dateTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(timestamp), 
zoneId);
@@ -605,6 +605,13 @@ public abstract class AbstractClient {
       if (hasResultSet) {
         ResultSet resultSet = statement.getResultSet();
         output(resultSet, printToConsole, zoneId);
+        if (resultSet != null) {
+          try {
+            resultSet.close();
+          } catch (SQLException e) {
+            System.out.println("Cannot close resultSet because: " + 
e.getMessage());
+          }
+        }
       }
       System.out.println("Execute successfully. Type `help` to get more 
information.");
     } catch (Exception e) {
diff --git a/iotdb-cli/src/main/java/org/apache/iotdb/cli/client/Client.java 
b/iotdb-cli/src/main/java/org/apache/iotdb/cli/client/Client.java
index da0d8b2..c9d1d65 100644
--- a/iotdb-cli/src/main/java/org/apache/iotdb/cli/client/Client.java
+++ b/iotdb-cli/src/main/java/org/apache/iotdb/cli/client/Client.java
@@ -82,6 +82,7 @@ public class Client extends AbstractClient {
     hf.setWidth(MAX_HELP_CONSOLE_WIDTH);
     CommandLine commandLine = null;
     CommandLineParser parser = new DefaultParser();
+    String[] newArgs = null;
 
     if (args == null || args.length == 0) {
       System.out.println(
@@ -92,9 +93,9 @@ public class Client extends AbstractClient {
       return;
     }
     init();
-    args = removePasswordArgs(args);
+    newArgs = removePasswordArgs(args);
     try {
-      commandLine = parser.parse(options, args);
+      commandLine = parser.parse(options, newArgs);
       if (commandLine.hasOption(HELP_ARGS)) {
         hf.printHelp(SCRIPT_HINT, options, true);
         return;
@@ -144,7 +145,7 @@ public class Client extends AbstractClient {
             String[] cmds = s.trim().split(";");
             for (int i = 0; i < cmds.length; i++) {
               String cmd = cmds[i];
-              if (cmd != null && !cmd.trim().equals("")) {
+              if (cmd != null && !"".equals(cmd.trim())) {
                 OperationResult result = handleInputCmd(cmd, connection);
                 switch (result) {
                   case RETURN_OPER:
@@ -170,6 +171,9 @@ public class Client extends AbstractClient {
     }
   }
 
+  /**
+   * @deprecated this method has been deprecated.
+   */
   @Deprecated
   private static Completer[] getCommandCompleter() {
     List<String> candidateStrings = new ArrayList<>();
@@ -189,7 +193,7 @@ public class Client extends AbstractClient {
       @Override
       public boolean isDelimiterChar(CharSequence buffer, int pos) {
         char c = buffer.charAt(pos);
-        return (Character.isWhitespace(c) || c == '(' || c == ')' || c == ',');
+        return Character.isWhitespace(c) || c == '(' || c == ')' || c == ',';
       }
     };
     final ArgumentCompleter argCompleter = new ArgumentCompleter(delim, 
strCompleter);
@@ -214,7 +218,7 @@ public class Client extends AbstractClient {
     StringsCompleter setCompleter = new StringsCompleter(Arrays.asList("set", 
"show")) {
       @Override
       public int complete(String buffer, int cursor, List<CharSequence> 
candidates) {
-        return buffer != null && (buffer.equals("set") || 
buffer.equals("show"))
+        return buffer != null && ("set".equals(buffer) || 
"show".equals(buffer))
             ? super.complete(buffer, cursor, candidates) : -1;
       }
     };
@@ -248,7 +252,7 @@ public class Client extends AbstractClient {
     StringsCompleter insertCompleter = new 
StringsCompleter(Arrays.asList("insert")) {
       @Override
       public int complete(String buffer, int cursor, List<CharSequence> 
candidates) {
-        return buffer != null && (buffer.equals("insert")) ? super
+        return buffer != null && ("insert".equals(buffer)) ? super
             .complete(buffer, cursor, candidates) : -1;
       }
     };
diff --git a/iotdb-cli/src/main/java/org/apache/iotdb/cli/client/WinClient.java 
b/iotdb-cli/src/main/java/org/apache/iotdb/cli/client/WinClient.java
index be7f0fd..4e9e2e5 100644
--- a/iotdb-cli/src/main/java/org/apache/iotdb/cli/client/WinClient.java
+++ b/iotdb-cli/src/main/java/org/apache/iotdb/cli/client/WinClient.java
@@ -46,6 +46,7 @@ public class WinClient extends AbstractClient {
     hf.setWidth(MAX_HELP_CONSOLE_WIDTH);
     CommandLine commandLine = null;
     CommandLineParser parser = new DefaultParser();
+    String[] newArgs = null;
 
     if (args == null || args.length == 0) {
       System.out.println("Require more params input, please check the 
following hint.");
@@ -55,10 +56,10 @@ public class WinClient extends AbstractClient {
 
     init();
 
-    args = removePasswordArgs(args);
+    newArgs = removePasswordArgs(args);
 
     try {
-      commandLine = parser.parse(options, args);
+      commandLine = parser.parse(options, newArgs);
       if (commandLine.hasOption(HELP_ARGS)) {
         hf.printHelp(IOTDB_CLI_PREFIX, options, true);
         return;
@@ -105,7 +106,7 @@ public class WinClient extends AbstractClient {
             String[] cmds = s.trim().split(";");
             for (int i = 0; i < cmds.length; i++) {
               String cmd = cmds[i];
-              if (cmd != null && !cmd.trim().equals("")) {
+              if (cmd != null && !"".equals(cmd.trim())) {
                 OperationResult result = handleInputCmd(cmd, connection);
                 switch (result) {
                   case RETURN_OPER:
diff --git 
a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/CsvTestDataGen.java 
b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/CsvTestDataGen.java
index d4af847..b8b497c 100644
--- a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/CsvTestDataGen.java
+++ b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/CsvTestDataGen.java
@@ -28,18 +28,26 @@ import java.io.OutputStreamWriter;
 @Deprecated
 public class CsvTestDataGen {
 
+  private CsvTestDataGen() {
+
+  }
+
+  private static final String PATHS = 
"Time,root.fit.p.s1,root.fit.d1.s1,root.fit.d1.s2,root.fit.d2."
+      + "s1,root.fit.d2.s3";
   private static String[] iso = {
-      
"Time,root.fit.p.s1,root.fit.d1.s1,root.fit.d1.s2,root.fit.d2.s1,root.fit.d2.s3",
+      PATHS,
       "1970-01-01T08:00:00.001+08:00,,1,pass,1,1", 
"1970-01-01T08:00:00.002+08:00,,2,pass,,",
       "1970-01-01T08:00:00.003+08:00,,3,pass,,", 
"1970-01-01T08:00:00.004+08:00,4,,,4,4"};
   private static String[] defaultLong = {
-      
"Time,root.fit.p.s1,root.fit.d1.s1,root.fit.d1.s2,root.fit.d2.s1,root.fit.d2.s3",
+      PATHS,
       "1,,1,pass,1,1",
       "2,,2,pass,,", "1970-01-01T08:00:00.003+08:00,,3,pass,,", "3,4,,,4,4"};
   private static String[] userSelfDefine = {
-      
"Time,root.fit.p.s1,root.fit.d1.s1,root.fit.d1.s2,root.fit.d2.s1,root.fit.d2.s3",
+      PATHS,
       "1971,,1,pass,1,1",
       "1972,,2,pass,,", "1973-01-01T08:00:00.003+08:00,,3,pass,,", 
"1974,4,,,4,4"};
+  private static FileOutputStream fos = null;
+  private static OutputStreamWriter osw = null;
   private static BufferedWriter bw = null;
   private static final String USER_DIR = "user.dir";
 
@@ -51,7 +59,7 @@ public class CsvTestDataGen {
   public static String isoDataGen() {
     String path = System.getProperties().getProperty(USER_DIR) + 
"/src/test/resources/iso.csv";
     File file = new File(path);
-    writeDataFrom(file);
+    writeDataFrom(file, iso);
     return path;
   }
 
@@ -64,7 +72,7 @@ public class CsvTestDataGen {
     String path =
         System.getProperties().getProperty(USER_DIR) + 
"/src/test/resources/defaultLong.csv";
     File file = new File(path);
-    writeDataFrom(file);
+    writeDataFrom(file, defaultLong);
     return path;
   }
 
@@ -77,17 +85,19 @@ public class CsvTestDataGen {
     String path =
         System.getProperties().getProperty(USER_DIR) + 
"/src/test/resources/userSelfDefine.csv";
     File file = new File(path);
-    writeDataFrom(file);
+    writeDataFrom(file, userSelfDefine);
     return path;
   }
 
-  private static void writeDataFrom(File file) {
+  private static void writeDataFrom(File file, String[] info) {
     try {
       if (!file.exists()) {
         file.createNewFile();
       }
-      bw = new BufferedWriter(new OutputStreamWriter(new 
FileOutputStream(file)));
-      for (String str : userSelfDefine) {
+      fos = new FileOutputStream(file);
+      osw = new OutputStreamWriter(fos);
+      bw = new BufferedWriter(osw);
+      for (String str : info) {
         bw.write(str + "\n");
       }
       bw.flush();
@@ -99,6 +109,8 @@ public class CsvTestDataGen {
     } finally {
       try {
         bw.close();
+        osw.close();
+        fos.close();
       } catch (IOException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
diff --git a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java 
b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java
index 3292ec8..427aa8a 100644
--- a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java
+++ b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java
@@ -44,6 +44,8 @@ import org.apache.iotdb.cli.exception.ArgsErrorException;
 import org.apache.iotdb.jdbc.Config;
 import org.apache.iotdb.jdbc.IoTDBConnection;
 import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Export CSV file.
@@ -65,6 +67,8 @@ public class ExportCsv extends AbstractCsvTool {
 
   private static String targetDirectory;
 
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ExportCsv.class);
+
   /**
    * main function of export csv tool.
    */
@@ -77,14 +81,14 @@ public class ExportCsv extends AbstractCsvTool {
     CommandLineParser parser = new DefaultParser();
 
     if (args == null || args.length == 0) {
-      System.out.println("[ERROR] Too few params input, please check the 
following hint.");
+      LOGGER.error("Too few params input, please check the following hint.");
       hf.printHelp(TSFILEDB_CLI_PREFIX, options, true);
       return;
     }
     try {
       commandLine = parser.parse(options, args);
     } catch (ParseException e) {
-      System.out.println(e.getMessage());
+      LOGGER.error(e.getMessage());
       hf.printHelp(TSFILEDB_CLI_PREFIX, options, true);
       return;
     }
@@ -122,20 +126,16 @@ public class ExportCsv extends AbstractCsvTool {
         dumpFromSqlFile(sqlFile);
       }
     } catch (ClassNotFoundException e) {
-      System.out.println(
-          "[ERROR] Failed to dump data because cannot find TsFile JDBC Driver, 
"
+      LOGGER.error(
+          "Failed to dump data because cannot find TsFile JDBC Driver, "
               + "please check whether you have imported driver or not");
     } catch (SQLException e) {
-      System.out.println(
-          String
-              .format("[ERROR] Encounter an error when dumping data, error is 
%s", e.getMessage()));
+      LOGGER.error("Encounter an error when dumping data, error is {}", 
e.getMessage());
     } catch (IOException e) {
-      System.out
-          .println(String.format("[ERROR] Failed to operate on file, because 
%s", e.getMessage()));
+      LOGGER.error("Failed to operate on file, because {}", e.getMessage());
     } catch (TException e) {
-      System.out.println(
-          String.format("[ERROR] Encounter an error when connecting to server, 
because %s",
-              e.getMessage()));
+      LOGGER.error("Encounter an error when connecting to server, because {}",
+              e.getMessage());
     } catch (ArgsErrorException e) {
       e.printStackTrace();
     } finally {
@@ -222,7 +222,7 @@ public class ExportCsv extends AbstractCsvTool {
         try {
           dumpResult(sql, index);
         } catch (SQLException e) {
-          System.out.println(String.format("[ERROR] Cannot dump data for 
statment %s, because %s", sql, e.getMessage()));
+          LOGGER.error("Cannot dump data for statment {}, because {}", sql, 
e.getMessage());
         }
         index++;
       }
@@ -238,17 +238,19 @@ public class ExportCsv extends AbstractCsvTool {
    */
   private static void dumpResult(String sql, int index)
       throws SQLException {
-    BufferedWriter writer;
+    FileWriter fw = null;
+    BufferedWriter bw = null;
     final String path = targetDirectory + DUMP_FILE_NAME + index + ".csv";
     try {
       File tf = new File(path);
       if (!tf.exists() && !tf.createNewFile()) {
-        System.out.println("[ERROR] Could not create target file for sql 
statement: " + sql);
-        return;
+          LOGGER.error("Could not create target file for sql statement: {}", 
sql);
+          return;
       }
-      writer = new BufferedWriter(new FileWriter(tf));
+      fw = new FileWriter(tf);
+      bw = new BufferedWriter(fw);
     } catch (IOException e) {
-      System.out.println(e.getMessage());
+      LOGGER.error(e.getMessage());
       return;
     }
 
@@ -261,65 +263,70 @@ public class ExportCsv extends AbstractCsvTool {
       // write data in csv file
       for (int i = 1; i <= count; i++) {
         if (i < count) {
-          writer.write(metadata.getColumnLabel(i) + ",");
+          bw.write(metadata.getColumnLabel(i) + ",");
         } else {
-          writer.write(metadata.getColumnLabel(i) + "\n");
+          bw.write(metadata.getColumnLabel(i) + "\n");
         }
       }
       while (rs.next()) {
-        if (rs.getString(1) == null || 
rs.getString(1).toLowerCase().equals("null")) {
-          writer.write(",");
+        if (rs.getString(1) == null || 
"null".equalsIgnoreCase(rs.getString(1))) {
+          bw.write(",");
         } else {
           ZonedDateTime dateTime;
           switch (timeFormat) {
             case DEFAULT_TIME_FORMAT:
             case "default":
               dateTime = 
ZonedDateTime.ofInstant(Instant.ofEpochMilli(rs.getLong(1)), zoneId);
-              writer.write(dateTime.toString() + ",");
+              bw.write(dateTime.toString() + ",");
               break;
             case "timestamp":
             case "long":
             case "nubmer":
-              writer.write(rs.getLong(1) + ",");
+              bw.write(rs.getLong(1) + ",");
               break;
             default:
               dateTime = 
ZonedDateTime.ofInstant(Instant.ofEpochMilli(rs.getLong(1)), zoneId);
-              
writer.write(dateTime.format(DateTimeFormatter.ofPattern(timeFormat)) + ",");
+              
bw.write(dateTime.format(DateTimeFormatter.ofPattern(timeFormat)) + ",");
               break;
           }
 
           for (int j = 2; j <= count; j++) {
             if (j < count) {
-              if (rs.getString(j).equals("null")) {
-                writer.write(",");
+              if ("null".equals(rs.getString(j))) {
+                bw.write(",");
               } else {
-                writer.write(rs.getString(j) + ",");
+                bw.write(rs.getString(j) + ",");
               }
             } else {
-              if (rs.getString(j).equals("null")) {
-                writer.write("\n");
+              if ("null".equals(rs.getString(j))) {
+                bw.write("\n");
               } else {
-                writer.write(rs.getString(j) + "\n");
+                bw.write(rs.getString(j) + "\n");
               }
             }
           }
         }
       }
-      System.out
-          .println(String
-              .format("[INFO] Statement [%s] has dumped to file %s 
successfully! It costs %d ms.",
-                  sql, path, (System.currentTimeMillis() - startTime)));
+      LOGGER.info("Statement [{}] has dumped to file {} successfully! It costs 
{}ms.",
+                  sql, path, System.currentTimeMillis() - startTime);
     } catch (IOException e) {
-      System.out.println(e.getMessage());
+      LOGGER.error(e.getMessage());
     } finally {
       try {
-        writer.flush();
-        writer.close();
+        if (rs != null) {
+          rs.close();
+        }
+        if (bw != null) {
+          bw.close();
+        }
+        if (fw != null) {
+          fw.close();
+        }
       } catch (IOException e) {
-        System.out.println(e.getMessage());
+        LOGGER.error(e.getMessage());
       }
       statement.close();
     }
   }
 
-}
\ No newline at end of file
+}
diff --git a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ImportCsv.java 
b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ImportCsv.java
index 9abb5f7..21b85d5 100644
--- a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ImportCsv.java
+++ b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ImportCsv.java
@@ -121,16 +121,20 @@ public class ImportCsv extends AbstractCsvTool {
    */
   private static void loadDataFromCSV(File file, int index) {
     Statement statement = null;
+    FileReader fr = null;
     BufferedReader br = null;
+    FileWriter fw = null;
     BufferedWriter bw = null;
     File errorFile = new File(errorInsertInfo + index);
     boolean errorFlag = true;
     try {
-      br = new BufferedReader(new FileReader(file));
+      fr = new FileReader(file);
+      br = new BufferedReader(fr);
       if (!errorFile.exists()) {
         errorFile.createNewFile();
       }
-      bw = new BufferedWriter(new FileWriter(errorFile));
+      fw = new FileWriter(errorFile);
+      bw = new BufferedWriter(fw);
 
       String header = br.readLine();
 
@@ -150,8 +154,7 @@ public class ImportCsv extends AbstractCsvTool {
 
       String[] strHeadInfo = header.split(",");
       if (strHeadInfo.length <= 1) {
-        System.out.println("[ERROR] The CSV file" + file.getName()
-            + " illegal, please check first line");
+        LOGGER.error("The CSV file {} illegal, please check first line", 
file.getName());
         return;
       }
 
@@ -166,9 +169,10 @@ public class ImportCsv extends AbstractCsvTool {
           timeseriesDataType.put(resultSet.getString(1),
               resultSet.getString(2));
         } else {
-          String errorInfo = String.format("[ERROR] Database cannot find %s in 
%s, stop import!",
+          String errorInfo = String.format("Database cannot find %s in %s, 
stop import!",
+              strHeadInfo[i], file.getAbsolutePath());
+          LOGGER.error("Database cannot find {} in {}, stop import!",
               strHeadInfo[i], file.getAbsolutePath());
-          System.out.println(errorInfo);
           bw.write(errorInfo);
           errorFlag = false;
           return;
@@ -234,9 +238,8 @@ public class ImportCsv extends AbstractCsvTool {
         statement.clearBatch();
         count = 0;
         tmp.clear();
-        System.out.println(String.format("[INFO] Load data from %s 
successfully,"
-                + " it takes %dms", file.getName(),
-            (System.currentTimeMillis() - startTime)));
+        LOGGER.info("Load data from {} successfully, it takes {}ms", 
file.getName(),
+            System.currentTimeMillis() - startTime);
       } catch (SQLException e) {
         bw.write(e.getMessage());
         bw.newLine();
@@ -244,16 +247,22 @@ public class ImportCsv extends AbstractCsvTool {
       }
 
     } catch (FileNotFoundException e) {
-      System.out.println("[ERROR] Cannot find " + file.getName());
+      LOGGER.error("Cannot find {}", file.getName());
     } catch (IOException e) {
-      System.out.println("[ERROR] CSV file read exception!" + e.getMessage());
+      LOGGER.error("CSV file read exception! {}", e.getMessage());
     } catch (SQLException e) {
-      System.out.println("[ERROR] Database connection exception!" + 
e.getMessage());
+      LOGGER.error("Database connection exception! {}", e.getMessage());
     } finally {
       try {
+        if (fr != null) {
+          fr.close();
+        }
         if (br != null) {
           br.close();
         }
+        if (fw != null) {
+          fw.close();
+        }
         if (bw != null) {
           bw.close();
         }
@@ -263,9 +272,8 @@ public class ImportCsv extends AbstractCsvTool {
         if (errorFlag) {
           FileUtils.forceDelete(errorFile);
         } else {
-          System.out.println(String.format(
-              "[ERROR] Format of some lines in %s error, please check %s for 
more information",
-              file.getAbsolutePath(), errorFile.getAbsolutePath()));
+          LOGGER.error("Format of some lines in {} error, please check {} for 
more "
+                  + "information", file.getAbsolutePath(), 
errorFile.getAbsolutePath());
         }
       } catch (SQLException e) {
         System.out.println("[ERROR] Sql statement can not be closed ! " + 
e.getMessage());
@@ -330,14 +338,14 @@ public class ImportCsv extends AbstractCsvTool {
     CommandLineParser parser = new DefaultParser();
 
     if (args == null || args.length == 0) {
-      System.out.println("[ERROR] Too few params input, please check the 
following hint.");
+      LOGGER.error("Too few params input, please check the following hint.");
       hf.printHelp(TSFILEDB_CLI_PREFIX, options, true);
       return;
     }
     try {
       commandLine = parser.parse(options, args);
     } catch (ParseException e) {
-      System.out.println(e.getMessage());
+      LOGGER.error(e.getMessage());
       hf.printHelp(TSFILEDB_CLI_PREFIX, options, true);
       return;
     }
@@ -360,7 +368,7 @@ public class ImportCsv extends AbstractCsvTool {
     } catch (ArgsErrorException e) {
       // ignored
     } catch (Exception e) {
-      System.out.println(String.format("[ERROR] Encounter an error, because 
%s", e.getMessage()));
+      LOGGER.error("Encounter an error, because {}", e.getMessage());
     } finally {
       reader.close();
     }
@@ -395,15 +403,14 @@ public class ImportCsv extends AbstractCsvTool {
       }
 
     } catch (ClassNotFoundException e) {
-      System.out.println(
-          "[ERROR] Failed to dump data because cannot find TsFile JDBC Driver, 
"
+      LOGGER.error(
+          "Failed to dump data because cannot find TsFile JDBC Driver, "
               + "please check whether you have imported driver or not");
     } catch (TException e) {
-      System.out.println(
-          String.format("[ERROR] Encounter an error when connecting to server, 
because %s",
-              e.getMessage()));
+      LOGGER.error("Encounter an error when connecting to server, because {}",
+          e.getMessage());
     } catch (Exception e) {
-      System.out.println(String.format("[ERROR] Encounter an error, because 
%s", e.getMessage()));
+      LOGGER.error("Encounter an error, because {}", e.getMessage());
     } finally {
       if (connection != null) {
         connection.close();
@@ -415,9 +422,7 @@ public class ImportCsv extends AbstractCsvTool {
     if (file.getName().endsWith(FILE_SUFFIX)) {
       loadDataFromCSV(file, 1);
     } else {
-      System.out.println(
-              "[WARN] File " + file.getName() + " should ends with '.csv' "
-                      + "if you want to import");
+      LOGGER.warn("File {} should ends with '.csv' if you want to import", 
file.getName());
     }
   }
 
@@ -429,9 +434,7 @@ public class ImportCsv extends AbstractCsvTool {
           loadDataFromCSV(subFile, i);
           i++;
         } else {
-          System.out.println(
-                  "[WARN] File " + subFile.getName() + " should ends with 
'.csv' "
-                          + "if you want to import");
+          LOGGER.warn("File {} should ends with '.csv' if you want to import", 
file.getName());
         }
       }
     }

Reply via email to