无法使用java notes api打开数据库

我正在尝试使用java程序在本地控制我的Lotus笔记,以便自动发送电子邮件。 尝试获取数据库对象时遇到以下问题。

try { NotesThread.sinitThread(); Session s = NotesFactory.createSession(); Database db = s.getDatabase("", "mail/xxxx.nsf") } finally { NotesThread.stermThread(); } 

我得到以下例外:

 NotesException: Database open failed (%1) at lotus.domino.local.Database.Nopen(Native Method) at lotus.domino.local.Database.open(Unknown Source) 

我已将我的nsf文件和Notes.jar复制到我的类路径,任何人都知道这有什么问题?

有几件事需要检查。

第一次改变:

 Session s = NotesFactory.createSession(); 

至:

 Session s = NotesFactory.createSession((String) null, (String) null, password); 

如果仍然无法正常工作则更改:

 Database db = s.getDatabase("", "mail/xxxx.nsf") 

至:

 Database db = s.getDatabase((String) null, "mail/xxxx.nsf") 

我还建议养成回收Domino对象的习惯。

您无需关闭Lotus Notes。 您正在使用的类不会驱动Notes UI。 它们使用“后端”存储对象。 他们正在使用Note C API来解决任何锁定问题。

NotesFactory.createSession运行时是否提示您输入用户名和密码?

您提到您已将NSF文件复制到类路径中。 为什么?? Lotus Notes类通常在Notes数据根目录中查找NSF文件,该目录由Notes客户机安装创建。 因此,您的NSF文件应该类似于Program Files(x86)\ IBM \ Lotus \ Notes \ Data \ Mail \ xxxx.NSF。