I have made a database in Mongodb and a collection with a few entries.I want to search for an entry using Java and also display it. I'm using Netbeans as my IDE. I tried searching all over the internet but couldn't find anything relevant. I'm new to Java and Mongodb.
DBObject result = new Mongo().getDb("yourDatabaseName").getCollection("yourTableName").findOne(new BasicDBObject("id", id), new BasicDBObject("specialColumn", 1));
return result.get("specialColumn")
This example will search for the field "specialColumn" in the collection "yourTableName" with the id "id"! There are more methods provided like .find(), where you can process with a DBCursor to check the results!
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments