Open Lotus Notes database
This task use java to open Lotus Notes database.
Open Lotus Notes database using DbDirectory
- Create openDatabase method as following
- Call openDatabase method as following
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; }
No comments:
Post a Comment