Examples: ParentDatabase property (Document - Java)

This agent demonstrates a function that gets the parent database given a Document object.

import lotus.domino.*;
import java.util.Vector;
public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();
      // (Your code goes here) 
      Database db = session.getDatabase(
                  "NotesUA1", "dbexamples");
      DocumentCollection dc = db.getAllDocuments();
      Document doc = dc.getFirstDocument();
      parentdb(doc);
  
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
  
  public void parentdb(Document d) {
    try {
      Database db = d.getParentDatabase();
      System.out.println("Parent database is \"" +
      db.getTitle() + "\" (" + db.getFileName() + ")");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}