packagecom.mongodb.util;importjava.util.ArrayList;importjava.util.Iterator;importjava.util.List;importcom.alibaba.fastjson.JSONArray;importcom.alibaba.fastjson.JSONObject;importcom.mongodb.BasicDBObject;importcom.mongodb.DB;importcom.mongodb.DBCursor;importcom.mongodb.DBObject;importcom.mongodb.MongoClient;importcom.mongodb.MongoCredential;importcom.mongodb.ServerAddress;importcom.mongodb.WriteResult;importcom.mongodb.util.DBConnection.DriverName;public classCrud {static DB mongoConn = null;public static voidConnect(DBConnection dbCon) {if (dbCon.getDriverName() ==DriverName.mongodb) {
ServerAddress serverAddress= newServerAddress(dbCon.getServerHost(), Integer.valueOf(dbCon.getServerPort()));
List addrs = new ArrayList<>();
addrs.add(serverAddress);
MongoCredential credential=MongoCredential.createScramSha1Credential(dbCon.getUserName(), dbCon.getSource(), dbCon.getPassword().t