package kenny.remote;
imp
imp
imp
imp
imp
imp
/**
* @author Kenny
* example:java程序遠(yuǎn)程訪問Domino服務(wù)器
*/
public class ConnectDomino {
//要訪問的Domino服務(wù)器域名,也可以用IP,默認(rèn)的DIIOP端口是63148,若不知道端口,請?jiān)儐柟芾韱T
private final static String HOST = "oa.abc.com.cn:63148";
//用戶名必須是name.nsf中注冊的用戶名,當(dāng)然如果服務(wù)器允許匿名訪問,這可以不需要此用戶名
private final static String USERNAME = "admin";
private final static String PASSWORD = "admin";
public void getDominoDB(){
Session session = null;
Database db = null;
View view = null;
Document doc = null,docx = null;
try{
//建立連接會(huì)話,若匿名訪問,用NotesFactory.createSession(HOST)即可
session = NotesFactory.createSession(HOST, USERNAME, PASSWORD);
db = session.getDatabase("SvrName", "DBName.nsf");
view = db.getView("ViewName");
doc = view.getFirstDocument();
while(doc != null){
//Process the Document doc
System.out.println(doc.getCreated());
//Then get the next document
docx = view.getNextDocument(doc);
//recycle the document we're done with,in the loop body,that's necessary
if(doc != null) doc.recycle();
doc = docx;
if(docx != null) docx.recycle();
}
}catch(NotesException e){
e.printStackTrace();
}finally{
try{//all of the domino objects must be recycle
if(docx != null) docx.recycle();
if(doc != null) doc.recycle();
if(view != null) view.recycle();
if(db != null) db.recycle();
if(session != null) session.recycle();
}catch(NotesException eRecycle){
eRecycle.printStackTrace();
}
}
}
}
另外,java程序的類路徑必須包含NCSO.jar,此包可以從安裝了Domino服務(wù)器或者Domino Designer客戶端軟件的計(jì)算機(jī)上獲得,具體路徑為\Da