Retrieve list of databases on Lotus Notes server
This task use java to retrieve list of databases on Lotus Notes server.
Retrieve list of databases using DbDirectory
- Create listDatabase method as following
- Call listDatabase method as following
try { String idfile = "path to your id file"; String password = "your password"; String server = "your server, empty if local"; NotesThread.sinitThread(); Session s = NotesFactory.createSessionWithFullAccess(); s.createRegistration().switchToID(idfile, password); List<Database> dblist = listDatabase(s, server); for (int i = 0; i < dblist.size(); i++) { Database db = dblist.get(i); logger.info(db.getTitle() + " | " + db.getFilePath()); db.recycle(); } s.recycle(); } catch (Exception e) { logger.info("", e); }listDatabase method
private List<Database> listDatabase(Session session, String server) throws Exception { List<Database> tag = new ArrayList<Database>(); DbDirectory dir = session.getDbDirectory(server); Database db = dir.getFirstDatabase(DbDirectory.DATABASE); while (db != null) { tag.add(db); db = dir.getNextDatabase(); } db = dir.getFirstDatabase(DbDirectory.TEMPLATE); while (db != null) { tag.add(db); db = dir.getNextDatabase(); } return tag; }
No comments:
Post a Comment