Thursday 22 December 2011

Open Lotus Notes database

Open Lotus Notes database
This task use java to open Lotus Notes database.
Open Lotus Notes database using DbDirectory
  1. Create openDatabase method as following
  2. Call openDatabase method as following
Call method
try {
    String idfile = "path to your id file";
    String password = "your password";
    // <server>!!<filepath> | <filepath>
    String filename = "path to database file";
    NotesThread.sinitThread();
    Session s = NotesFactory.createSessionWithFullAccess();
    s.createRegistration().switchToID(idfile, password);
    Database d = openDatabase(s, filename);
    logger.info(d.getTitle() + " | " + d.getFilePath());
    d.recycle();
    s.recycle();
} catch (Exception e) {
    logger.info("", e);
}
    
openDatabase method
private Database openDatabase(Session session, String filename) throws Exception {
    int pos = filename.indexOf("!!");
    Database tag = null;
    if (pos < 0) {
        DbDirectory dir = session.getDbDirectory("");
        tag = dir.openDatabase(filename);
    } else {  
        String server = filename.substring(0, pos);
        String path = filename.substring(pos + 2, filename.length());
        DbDirectory dir = session.getDbDirectory(server);
        tag = dir.openDatabase(path);
    }
    return tag;
}
    

  Protected by Copyscape Online Copyright Protection

No comments:

Post a Comment