1.MongoClient mongoClient=new MongoCliient();
DB db=mongoClient.getDB("test");
DBCollection conn = db.getCollection("user");
User user = new User()
user.set();....
转为dbObject再插入到Mongodb数据库
DBObject dbObject = (DBObject) JSON.parse(gson.toJson(user)); #插入到mongodb库
user.insert(dbObject );
查询
DBCursor cursor =conn.find();
遍历
while(cursor.hasNext()){
......//操作游标
}