【问题标题】:Fail to open Database using java notes api使用 java notes api 无法打开数据库
【发布时间】:2013-03-16 03:42:15
【问题描述】:

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

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 吗? - 你真的尝试过吗?不可能那么难。许多程序确实会锁定文件,那么您能否消除这个可能的问题?

标签: java lotus-notes


【解决方案1】:

有几件事要检查。

第一个变化:

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 对象的习惯。

【讨论】:

  • 非常感谢。在我更改 Session s = NotesFactory.createSession(); 之后现在可以了to Session s = NotesFactory.createSession((String) null, (String) null, password);
【解决方案2】:

您不需要关闭 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 之类的目录中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-23
    相关资源
    最近更新 更多