How to import / export all MongoDB database collections using mongodb java driver?

Is there any function to import and export all mongodb database collections using java driver.? for example, mongodumpand mongorestoreusing the command line.

+2
source share
4 answers

The short answer is no. These commands can only be invoked from the command line. You might consider getting all the data from all the collections, but they are expected to be slow.

You can read a discussion of this here.

Hope this helps

+1
source

( , )

mongodbdump-java-wrapper, mongodump.exe mongorestore.exe mongodb java.

: github. ( , /).

+1

, Mongo Java .

mongoimport mongorestore Java Runtime.

Runtime.getRuntime().exec("mongoimport -d <dbname> -h <>..");
0
mongodump --host localhost --port 27017 --db sample    

mongorestore --db sample --verbose d:/dump/sample/
0

Source: https://habr.com/ru/post/1653892/


All Articles