Fail to open Database using java notes api

烈酒焚心 提交于 2019-12-19 09:24:09

问题


I am trying to use a java program to control my lotus notes locally to send email automatically for me. I have encountered the following issues when trying to get a database object.

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

I got the following Exception:

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

I have copy my nsf file and Notes.jar to my classpath, anyone knows what is the problem with this?


回答1:


A couple of things to check.

First change:

Session s = NotesFactory.createSession();

to:

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

If it is still not working then change:

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

to:

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

I would also recommend to getting into the habit of recycling your Domino objects.




回答2:


You do not need to close Lotus Notes. The classes that you are using do not drive the Notes UI. They work with "back-end" storage objects. They are working with the Note C APIs to resolve any locks.

Are you prompted for your username and password with NotesFactory.createSession runs?

You mentioned that you copied the NSF file to your classpath. Why?? The Lotus Notes classes shuold normally Find NSF files in the Notes data root directory, which is created by your Notes client installlation. So your NSF file should be in something like Program Files (x86)\IBM\Lotus\Notes\Data\Mail\xxxx.NSF.



来源:https://stackoverflow.com/questions/15445297/fail-to-open-database-using-java-notes-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!