Package Kenny. Remote;
IMP ORT Lotus. Domino. database;
IMP ORT Lotus. Domino. Document;
IMP ORT Lotus. Domino. notesexception;
IMP ORT Lotus. Domino. notesfactory;
IMP ORT Lotus. Domino. Session;
IMP ORT Lotus. Domino. view;
/**
* @ Author Kenny
* Example: Java Program Remote access to the Domino server
*/
Public class connectdomino {
// The domain name of the Domino server to be accessed. You can also use an IP address. The default diiop port is 63148. If you do not know the port, ask the administrator.
Private Final Static string host = "oa.abc.com.com: 63148 ";
// The user name must be the user name registered in name. nsf. Of course, if the server permits anonymous access, this user name is not required.
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 {
// Establish a connection session. If anonymous access is performed, use 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 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 ();
}
}
}
}
In addition, the class path of the Java program must contain ncso. Jar. This package can be obtained from the computer where the Domino server or Domino designer client software is installed. The specific path is \ da.Ta \ domino \ Java.