无法使用java notes api打开数据库
我正在尝试使用java程序在本地控制lotus notes,以便为我自动发送电子邮件。我在尝试获取数据库对象时遇到了以下问题无法使用java notes api打开数据库,java,lotus-notes,Java,Lotus Notes,我正在尝试使用java程序在本地控制lotus notes,以便为我自动发送电子邮件。我在尝试获取数据库对象时遇到了以下问题 try { NotesThread.sinitThread(); Session s = NotesFactory.createSession(); Database db = s.getDatabase("", "mail/xxxx.nsf") } finally { NotesThread.stermThread(); } 我得到了以
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复制到我的类路径,有人知道这有什么问题吗 您不需要关闭Lotus Notes。您正在使用的类不会驱动Notes UI。它们使用“后端”存储对象。他们正在使用NotecAPI来解决任何锁 是否在NotesFactory.createSession运行时提示您输入用户名和密码
您提到您已将NSF文件复制到类路径。为什么?LotusNotes类shuold通常在Notes数据根目录中找到NSF文件,该目录由Notes客户端安装创建。因此,您的NSF文件应该位于类似Program Files(x86)\IBM\Lotus\Notes\Data\Mail\xxxx.NSF的文件中。需要检查一些内容 第一个变化:
Session s = NotesFactory.createSession();
致:
如果仍不工作,则更改:
Database db = s.getDatabase("", "mail/xxxx.nsf")
致:
我还建议养成回收Domino对象的习惯 运行此程序之前是否需要关闭Lotus Notes?-你真的试过这个吗?不会那么难的。很多程序都会锁定文件,所以您能尽可能地消除这个问题吗?非常感谢。在我更改会话s=NotesFactory.createSession()之后,现在一切正常;to Session s=NotesFactory.createSession((字符串)null,(字符串)null,密码);
Database db = s.getDatabase("", "mail/xxxx.nsf")
Database db = s.getDatabase((String) null, "mail/xxxx.nsf")