可以啊,你要直接用它的本身的两个jar文件,直接可以对象操作,不用jdbc的
解决方案 »
- hibernate是操作对象快还是写hql针对属性做update或delete快呢
- 如何进入服务器电脑的桌面?
- 当Hibernate的配置文件为cfg.xml时,进行如下初始化
- 时间段校验算法
- 值传递?
- java 图片处理
- 查看源文件问题
- 这是为什么?Can't make static reference to method void makeXMLTree(org.w3c.dom.Element, java.lang.
- 一个接口两套实现,如何动态切换?有没有可以套用的设计模式
- 如何在jsp取值栈中push的对象
- 如何将2000-5-5 10:10:10 转换成05月05日10时10分
- tomcat 多久重起一次?
1、直接使用Domino本身的jar(notes.jar或NCSO.jar)文件接口,这种连接方式需要Domino服务器启动DIIOP服务;
2、使用Domino的LDDJ(Lotus Domino Drivers for JDBC)接口,接口可以到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/oaunion.nsf/doc/05728898F1320F4F48256DF7004CFBE5?opendocument&skeyword=Corba
jdbc方式应该不能在jsp或javabean中使用吧,因为它会弹出密码输入框让你输入密码的;使用corba应该是可以的;第一种方式就不知道了,因为它要依靠客户端的。
第一种方式的例程:
import lotus.domino.*;
import java.net.*;
import java.io.*;
import java.util.*;public class ConnectToDomino
{
Session session = null;
String strServer = null;
String strUserName = null;
String strPassWord = null;
//构造函数
public ConnectToDomino(String Server,String User,String Pass) {
strServer = Server;
strUserName = User;
strPassWord = Pass;
setConnection();
}
//建立连接
public boolean setConnection() {
if(strServer==null || strUserName==null || strPassWord==null) return false;
try {
System.out.println("用户登录:" + strServer + "\t" + strUserName);
String IOR=GetIOR();
if(IOR!="")
System.out.println("成功取得IOR,开始创建session.....");
else
System.out.println("获取IOR失败!");
//session = NotesFactory.createSession(strServer,strUserName,strPassWord);
//session = NotesFactory.createSession(strServer,"","");
//session = NotesFactory.createSessionWithIOR(IOR); //匿名
session = NotesFactory.createSessionWithIOR(IOR,strUserName,strPassWord); //用户身份
System.out.println("成功登陆,登录信息:\n服务器名称:" + session.getServerName() + "\n登录用户名:" + session.getUserName() + "\n");
return true;
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
}
//获取IOR
public String GetIOR() {
InputStream bin;
String Result="";
int character;
try{
URL url = new URL("http://"+strServer+"/diiop_ior.txt");
bin = url.openStream();
while((character=bin.read())>0) {
Result += (char)character;
}
}
catch(Exception e){
e.printStackTrace();
}
return Result;
} //检索文档
public void Search(String SearchDB,String SearchFormular) {
try {
Database db = session.getDatabase(session.getServerName(),SearchDB);
System.out.println ("Searching:" + SearchFormular+"...");
DocumentCollection dc = db.search(SearchFormular);
Document docResult = dc.getFirstDocument();
if(docResult==null) return;
int i;
int j=0;
while (docResult != null) {
System.out.println(docResult.getItemValueString("FullName"));
docResult = dc.getNextDocument();
}
}catch(Exception e)
{
e.printStackTrace();
}
}
//创建文档
public boolean CreateNewDoc(String DBName,String formName,String[] FieldList,String[] ValueList,String AgentName) {
try{
Database db = session.getDatabase(session.getServerName(),DBName);
Document doc = db.createDocument();
Item item = doc.appendItemValue("form",formName);
doc.computeWithForm(true,false);
int i;
for(i=0;i<FieldList.length;i++){
item = doc.replaceItemValue(FieldList[i],ValueList[i]);
}
doc.save();
if(AgentName!=null || AgentName!="") {
Agent agent = db.getAgent(AgentName);
if(agent!=null) {
agent.run(doc.getNoteID());
}
}
return true;
}catch(Exception e)
{
e.printStackTrace();
return false;
}
}
//关闭
public void close() {
try{
session.recycle();
session = null;
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
附一个JSP的例子如下:
<%@ page contentType="text/html; charset=gb2312" 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>
thanks
以下是与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数据源连接失败" ) ;
}
与notes数据库建立链接不需要什么JDBC,除非你还需要将数据库导入到别的关系型数据库中,那使用JDBC是最好的
只要将domino jar放到classpath路经里进去 就可以import lotus.domino.*;
了吗?
另外,通过这种方式可以读写lotus数据库吧??
应该也可以写成连接池的方式来进行连接管理吧??不吝啬赐教!!!