@Override 数据库
public boolean update(String dbName, String collectionName, ide
DBObject oldValue, DBObject newValue) { spa
DB db = null; get
DBCollection dbCollection = null; it
WriteResult result = null; io
String resultString = null; date
if(oldValue.equals(newValue)){ exception
return true; request
}else{ 数据
try {
db = mongoClient.getDB(dbName); //获取数据库实例
dbCollection = db.getCollection(collectionName); //获取数据库中指定的collection集合
result = dbCollection.update(oldValue, newValue);
resultString = result.getError();
return (resultString!=null) ? false : true;
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
} finally{
if(null != db){
db.requestDone(); //关闭db
db = null;
}
}
}
return false;
}