I have a MongoCollection in which I assign a collection.
I\'m trying to find a user by his id.
user = (Document) usersCollection
Do this -
MongoClient client = new MongoClient();
DBObject resultObject = new BasicDBObject("_id", username);
MongoDatabase database = client.getDatabase("DBNAME");
MongoCollection collection = database.getCollection("COLLECTION_NAME");
DBObject dbObject = new BasicDBObject("_id", username);
resultObject = collection.find(dbObject).next();
String result = resultObject.get(YOUR_COLOUM_NAME);