如何将mongodb数据导出到远程系统

时间:2014-09-17 05:10:42

标签: java mongodb-java

我将mongodb数据导出到* .csv文件中。但问题是我想在远程系统中拥有转储或* .csv文件。在尝试的时候,我不打算!!

    Runtime runtime = Runtime.getRuntime();
    DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
    Date date = new Date();
    String xyz=dateFormat.format(date);
    String query="mongoexport --host "+" "+ipAdders+" "+"-d SMPP -c UserMessages
   --csv         --fieldFile /root/Documents/UserMessagesFileds.txt -o"+" "+xyz+".csv";
    try {
      Process process=runtime.exec(query);
      System.out.println(query);
      System.out.println(xyz);
      if( null!=process  && process.waitFor() == 0 &&process.exitValue()== 0 ){
         System.out.println("Command executed sucessfully"); 
      }
      else{

      }
      return true;
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }

此代码在我的系统中存储* .csv文件,但我希望它在远程系统中,如(192.168.0.139)。

1 个答案:

答案 0 :(得分:0)

您应该在系统上转储*.csv文件,然后使用Socket在计算机之间传输文件。