I am new to MongoDB and I play with it using the JAVA driver.
I have the following code
MongoClient client = new MongoClient(); DB d = client.getDB("world"); DBCollection c = d.getCollection("zips"); DBCursor cursor = c.find();
Now my question is that I want to use a simple cursor to go through documents. The getDB () method is deprecated, but it works great. The documentation mentioned that getDB can be replaced with MongoClient.getDatabase (); but getDatabase () returns MongoDatabase, not the database.
Can anyone point out the correct way to create a DBCursor without using the deprecated method. Thanks.
PS: I know that there are such frameworks as morphine, jongo, etc., but please do not allow their discussion. Currently, I want to use only the JAVA driver. EDIT: the difference is getting the cursor in the JAVA driver not between DB and MongoClient
source share