java 访问 domino_java程序远程访问Domino数据库简例

ort lotus.domino.Session;

import lotus.domino.View;

/**

* @author Kenny

* example:java程序远程访问Domino服务器

*/

public class ConnectDomino {

//要访问的Domino服务器域名,也可以用IP,默认的DIIOP端口是63148,若不知道端口,请询问管理员

private final static String HOST = "oa.abc.com.cn:63148";

//用户名必须是name.nsf中注册的用户名,当然如果服务器允许匿名访问,这可以不需要此用户名

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{

//建立连接会话,若匿名访问,用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();

}

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值