疯狂java


您现在的位置: 疯狂软件 >> 新闻资讯 >> 正文

java调用domino


 

java访问操作lotus domino数据库
有几种方式:  
  1、直接使用domino本身的jar文件接口,这种连接方式需要domino服务器启动diiop服务;  
  2、使用domino的lddj接口,接口可以到ibm的网站上去下载,这种连接方式只能在window环境下使用,需要安装notes客户端,使用id来验证的,需要手动输入密码;  
      http://www-12.lotus.com/ldd/doc/drivers/jdbc/1.5/lddj_help.nsf  
  3、使用corba来访问domino,这个比较烦,我至今没有调通  
  http://www.oaunion.com/oaunion/o ... pendocument&skeyword=corba发表者:slzhang
是可以通过java来取得domino的资料.也可以通过jsp来读domino里的资料,只要你在domino上打开diiop服务就可以.  
  附一个jsp的例子如下:  
  <%@   page   c   language="java"%>  
  <%@   page   import="com.dragon.*"   %>  
  <%@   page   import="lotus.domino.*"   %>  
  <%!    
  session   sess;  
  database   db;  
  view   view;  
  document   doc;  
  string   host   =   "",user   =   "",   pawd   =   "";  
    %>  
  <%    
  try{  
  sess   =   notesfactory.createsession("192.168.2.1","admin","12345678");  
  host   =   sess.getservername();  
  user   =   sess.getusername();  
  system.out.println("host:   "   +   host   +   ";   user:   "   +user);  
  db   =   sess.getdatabase(host,"fawen\sample.nsf",false);  
  view   =   db.getview("jsp");  
  doc   =   view.getfirstdocument();  
  out.println(db.gettitle());  
  }catch(notesexception   ne){  
  system.out.println("error:   "   +   ne.id   +   "   ==>   "   +   ne.getmessage());  
  }  
    %>  
    <html>  
    <head>  
    <title>jsp   get   domino   data</title>  
    </head>  
    <body>  
    <table   border="1"   bgcolor="#ff33cc">  
    <tr><th>   姓名</th><th>性别</th><th>生日</th><th>职务</th><th>职称</th><th>   部门</th></tr>  
    <%  
    while(doc!=null){  
    %>  
  <tr>  
   
  <td><%=   doc.getitemvalue("jname")   %></td>  
  <td><%=   doc.getitemvalue("jsex")   %></td>  
  <td><%=   doc.getitemvalue("jbirth")   %></td>  
  <td><%=   doc.getitemvalue("jjob")   %></td>  
  <td><%=   doc.getitemvalue("jjobtitle")   %></td>  
  <td><%=   doc.getitemvalue("jdept")   %></td>  
  </tr>  
  <%  
  doc   =   view.getnextdocument(doc);  
  }  
  out.println("host:   "   +   host   +   ";   user:   "   +user);  
  doc.recycle();  
  view.recycle();  
  db.recycle();  
  sess.recycle();  
  %>  
  </table>  
    </body>  
    </html>
发表者:cnhxjtoa
以前我写过domino5-->oracle8  
  以下是与domino建立链接的相关代码  
    import   lotus.domino.*;    
   
  try   {  
                         
                          system.out.println("开始notes数据源进行连接....");  
                          session   s   =   notesfactory.createsession(noteshost,username,userpassword);  
                          system.out.println("与notes数据源成功连接,现正在查找notes登录数据库oak.nsf");  
                          //定义全局性变量  
                          database   db   =   null;  
                          database   namesdb=null;  
                          view   view   =null;  
                          document   doc   =   null;  
                          string   namesuser="";  
                          db   =   s.getdatabase(s.getservername(),   sysinf.notes_dir   +"/oak.nsf");  
                          acl   acl   =   db.getacl();  
                          aclentry   entry   =   acl.getfirstentry();  
                          namesdb=s.getdatabase(s.getservername()   ,"names.nsf")   ;  
                          view   =   namesdb.getview("groups");  
                          do  
                          {  
                                  //具体分析每一个对象  
                                  switch   (entry.getusertype())   {  
                                          case   aclentry.type_mixed_group   :  
                                                  //混合组  
                                                  system.out.println("混合组     "+entry.getname())   ;break;  
                                          case   aclentry.type_person   :  
                                                  //个人  
                                                  namesuser=entry.getname().substring(3,entry.getname().indexof("/")     );  
                                                  addnotesuser(namesuser);  
                                                  system.out.println("个人   :   "+   namesuser)   ;  
                                                  break;  
                                          case   aclentry.type_person_group   :  
                                                  //个人群组  
                                                  system.out.println("个人群组:     "+entry.getname()   )   ;  
                                                  //names.nsf   中视图groups   文档members域有每一个用户  
                                                  doc   =   view.getfirstdocument();  
                                                  while   (doc   !=   null   &&   !doc.getfirstitem("listname").gettext().equals(entry.getname()   )       )  
                                                  {  
                                                          doc   =   view.getnextdocument(doc);  
                                                  }  
                                                  if   (doc!=null){  
                                                          enumeration   values   =   doc.getfirstitem("members").getvalues().elements();  
                                                          while   (values.hasmoreelements())   {  
                                                                  //将cn=administrator/o=autosoft只取它的名字administrator  
                                                                  namesuser=values.nextelement().tostring()   ;  
                                                                  namesuser=namesuser.substring(3,namesuser.indexof("/")   )   ;  
                                                                  addnotesuser(namesuser);  
                                                          }  
                                                  }  
                                                  break;  
                                          case   aclentry.type_server   :  
                                                  //服务器  
                                                  system.out.println("服务器     "+entry.getname())   ;break;  
                                          case   aclentry.type_server_group   :  
                                                  //服务器组  
                                                  system.out.println("服务器组     "+entry.getname())   ;break;  
                                          case   aclentry.type_unspecified   :  
                                                  //没有指定  
                                                  if(entry.getname().indexof("/")>1   )  
                                                  {  
                                                          namesuser=entry.getname().substring(3,entry.getname().indexof("/")     );  
                                                          addnotesuser(namesuser);  
                                                          system.out.println("找到一个没有指定类型的用户     "+entry.getname().substring(3,entry.getname().indexof("/")))   ;  
                                                          break;  
                                                  }  
                                                          else  
                                                          {  
                                                                  system.out.println("没有指定     "+entry.getname())   ;  
                                                                  break;  
                                                          }  
                                  }  
                          }   while   ((entry   =   acl.getnextentry(entry))   !=   null);  
                          system.out.println("用户导入完成")   ;  
                  }  
   
                  catch   (exception   ex)  
                  {  
                          ex.printstacktrace()   ;  
                          system.out.println("与notes数据源连接失败"   )   ;  
                  }