因为做的是EAI的项目,要集成原来的Domino应用,有一个修改Domino的需求,因为以前没有找到合适的方法,就对names.nsf数据库遍历了一遍用户,找到匹配的用户再修改,本来连接Domino就很慢,这样一来就更慢了,1155个用户光遍历一遍就用了2分多钟,后来一个同事找到一个方法,改完之后,竟然只用5秒钟就一切都搞定了:
int i = view.FTSearch("文件名", 3); //定位文件
就是这个方法,一下子让性能提升了60倍!
而且释放Domino的连接快了,出错的几率小多了,上午可能是因为修改密码的人多,造成了Domino的IIOP服务死了2次,希望这么改后就不再出现问题了。
还有一个问题就是,要修改IBM 的Portal的数据库的用户的密码,也没有找到定位用户的方法,目前也是一个个的遍历,找到匹配的用户名,再改,不过这个操作倒是很快,如果哪位兄弟知道定位IBM Portal的用户的数据库中某一个用户的方法,请不吝赐教,谢谢!
Domino这个东西我在2003年弄过一阶段,后来不再弄就忘的一干二净,现在又被它折磨!:o(
最近Portal越来越健壮,高兴ing……
//获取Domino的Session,这段代码从网上遍地都是
public static Session getDominoConnection(String serverHttp,
String user_name, String password) throws NotesException {
if (session == null) {
String ior = NotesFactory.getIOR(serverHttp);
session = NotesFactory.createSessionWithIOR(ior, user_name,
password);
}
return session;
}
//这个方法从网上就很难找到了
public static boolean changePWD(String new_pwd, PortalUser user) {
boolean b = false; //返回值变量
String file_name = null; //Domino中的用户文件名
View view = null; //Domino的结构
Document doc = null; //Domino的结构
String user_name = "rabbit8";
String pwd ="rabbit8";
String serverHttp = "172.168.0.1";//Domino的IP
try {
session = getDominoConnection(serverHttp, user_name, pwd); //获得Domino的Session
if (session != null) {
Database db = session.getDatabase("", "names.nsf");
if (db != null) {
view = db.getView("People");
if (view != null) {
int i = view.FTSearch(user_name, 3); //定位文件,具体可以查找Domino的书籍
doc = view.getFirstDocument();
while (doc != null) {
file_name = doc.getItemValueString("shortname");
if (file_name != null && file_name.equals(user_name)) {
Vector v_pwd = session.evaluate("@Password(" + '"' + new_pwd + '"' + ")");
String s_pwd = v_pwd.firstElement().toString();//返回加密的密码
doc.replaceItemValue("HttpPassword", s_pwd); //替换旧密码
doc.save(true); //保存更改
b = true;
}
doc = view.getNextDocument(doc);
}
if(doc != null){
doc.recycle();
doc = null;
}
if(view != null){
view.recycle();
view = null;
}
}
}
if(db != null){
db.recycle(); //关闭数据库
db = null;
}
if(session != null){
session.recycle();
session = null;
}
}
return b;
} catch (Exception e) {
System.out.println("Domino连接不正常,修改密码失败!错误====="+ e.getStackTrace());
e.printStackTrace();
return b;
} finally {
try {
if (doc != null) {
doc.recycle();
doc = null;
}
if (view != null) {
view.recycle();
view = null;
}
if (db != null) {
db.recycle();
db = null;
}
if (session != null) {
session.recycle();
session = null;
}
} catch (Exception e) {
e.printStackTrace();
return b;
}
}
}
}