The Mongo java documentation appears to have the following example for preparing a bulk insert:
DBCollection coll = getCollection("collectionName");
BulkWriteOperation builder = coll.initializeOrderedBulkOperation();
However, at least with the 3.0 version of their driver, getCollection
returns MongoCollection<Document>
instead of DBCollection
. I can find no alternative to the initializeOrderedBulkOperation
method.
I can find a bulkWrite
method but that seems to allow a variety of write methods and may not be properly optimized for the bulk inserts I need.
None of these classes are deprecated so I'm not clear on how to properly run a bulk insert.
This is the current 3.0BETA you are talking about. Yes there are new class interfaces but the way to access the interfaces used by prior and current versions has not changed. It's even listed right there in the documentation for DBCollection:
MongoClient mongoClient = new MongoClient(new ServerAddress("localhost", 27017));
DB db = mongo.getDB("mydb");
DBCollection collection = db.getCollection("test");
So you seem to have followed through .getDatabase()
rather than .getDB()