我正在尝试将Lotus Notes数据库中的数据访问到外部Java程序中,但是没有运气。
在便携式计算机上,我已经配置了IBM Domino 9.0.1服务器,并在其中创建了一个演示数据库。我的目标是通过外部Java代码访问该数据库中的数据。我还在配置Domino服务器的同一台笔记本电脑上安装了Netbeans和Eclipse。现在,我试图使用Notes.jar包中提供的类访问我的Java程序(netbeans / eclipse)中的demo Lotus Notes数据库,但无法打开数据库。
要完成任务,我已按照以下步骤操作:
在类中添加了以下代码: (假设Lotus.domino。*已在代码中导入)
public static void main(String [] args)
{
try{
NotesThread.sInitThread();
//Case1
Session session = NotesFactory.createSession()//Connect the server with server ID. Throws error 'Database has not been opened yet';
//Also tried following options. Note that I have assigned full access/manager rights to anonymous user on the demo database
//Case2
//Session session = NotesFactory.createSession((String)null);//Same result as first one [NotesFactory.createSession()]
//Case3
//Session session = NotesFactory.createSession((String)null,"Romil Handoo/dev","My_Domino_Internet_Password");//Connect the server as Romil Handoo/dev login. Throws error- Invalid User Id/Password. I am giving correct ID/password
//Case4
//Session session = NotesFactory.createSession((String)null,"","");//Access with anonymous user. Throws error 'Database has not been opened yet'**
Database dbDemo = session.getDatabase(session.getServer(), "demo/DemoDB.nsf");
//session.getServer() is returning my server name, which is Development/home.
//Also tried these, but same result each time:
//session.getDatabase("localhost:9595","demo/DemoDB.nsf")
//session.getDatabase("localhost","demo/DemoDB.nsf")
//session.getDatabase("127.0.0.1:9595","demo/DemoDB.nsf")
//session.getDatabase("127.0.0.1","demo/DemoDB.nsf")
//session.getDatabase("","demo/DemoDB.nsf")
//session.getDatabase((String)null,"demo/DemoDB.nsf")
//Following line throws exception 'Database has not been opened yet'
View vwDemo = dbDemo.getView("vwDemo");
}
catch(Exception ex)
{
System.out.println(ex.toString());
//For case 1, case 2, and case 4, error message is 'Database has not been opened yet'
//For case 3, error message is 'Invalid login id/password'
}
finally
{
NotesThread.stermThread();
}
}
请有人指导我如何通过外部Java代码连接到Domino数据库?对于所有这些步骤,我都引用了页面https://www.ibm.com/support/knowledgecenter/en/SSVRGU_9.0.1/basic/H_NOTESDATABASE_CLASS_JAVA.html
非常感谢
答案 0 :(得分:0)
检查DemoDB.nsf的ACL。如果不得不大胆猜测,我会说本地域服务器组在ACL中,并且标记为“服务器组”,但是您的代码正在建立客户端连接,因此,情况1、2和4失败。如果不是那样,那可能是其他访问问题。
情况3失败,因为您提供的是互联网密码,而不是实际用户ID文件的密码。 (使用Internet密码仅适用于NCSO.jar和IIOP访问,不适用于Notes.jar和NRPC访问。)