Java code for MongoDB