2016-02-12 313 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