2016-02-12 312 views
1

團隊,如何使用java程序執行mongoexport命令

我需要使用獨立Java程序從MongoDB中導出Collection。任何人都可以幫助我這麼做嗎?

謝謝

+0

到目前爲止您試過的任何東西? –

+0

是的,我已經嘗試了幾行代碼。 String expCommand =「mongoexport --d」+ database +「--out」+ exportPath +「--collection」+ collection; \t \t進程p = Runtime.getRuntime()。exec(expCommand); 仍然無法正常工作。 – Zeeshan

回答

1

可能你只是使用錯誤的參數嗎? 嘗試

String expCommand1 = "mongoexport --db "+database+" --out "+exportPath+" --collection "+collection; 
String expCommand2 = "mongoexport -d "+database+" --out "+exportPath+" --collection "+collection; 
+0

感謝Petr Star爲我工作:) – Zeeshan