JAVA/CORBA CLASSES


Examples: createDatabase method
This agent creates a local database named newdb.nsf unless a database by that name already exists.

import lotus.domino.*;
public class JavaAgent extends AgentBase {
 public void NotesMain() {
   try {
     Session session = getSession();
     AgentContext agentContext = session.getAgentContext();
     // (Your code goes here)
     DbDirectory dir = session.getDbDirectory(null);
     boolean found = false;
     Database db = dir.getFirstDatabase(DbDirectory.DATABASE);
     while (db != null) {
       String fn = db.getFileName();
       if (fn.equalsIgnoreCase("newdb.nsf")) found = true;
       db = dir.getNextDatabase(); }
     if (!found) {
       System.out.println("Not found, creating newdb.nsf");
       dir.createDatabase("newdb.nsf"); }
     else
       System.out.println("found, not creating newdb.nsf");
   } catch(Exception e) {
     e.printStackTrace();
   }
 }
}

See Also