【发布时间】:2018-10-31 07:31:21
【问题描述】:
我正在尝试将 Lotus Notes 数据库中的数据访问到外部 Java 程序中,但没有成功。
在我的笔记本电脑上,我配置了 IBM Domino 9.0.1 服务器,并在其中创建了一个演示数据库。我的目标是通过外部 Java 代码访问该数据库中的数据。我还在配置 Domino 服务器的同一台笔记本电脑上安装了 Netbeans 和 Eclipse。现在,我正在尝试使用 Notes.jar 包中提供的类访问我的 java 程序(netbeans/eclipse)中的演示 lotus notes 数据库,但无法打开数据库。
为了完成任务,我遵循了以下步骤:
- 将路径“C:\Program Files\IBM\Domino”添加到“Path”系统变量,并重新启动笔记本电脑。
- 在 Netbeans 中(也在 Eclipse 中尝试过),创建 Java 类(控制台应用程序),在类路径中添加 Notes.jar 文件(IBM/Domino/JVM/lib/ext/Notes.jar)(在 netbeans 中,添加 Notes.jar)。 jar 在 Resources 部分。在 Eclipse 中,将 Notes.jar 复制到 lib 文件夹中)。
-
在类中添加了以下代码: (假设 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
非常感谢
【问题讨论】:
标签: java lotus-notes