Examples: Accessing database properties using Java

This application gets the first database in the local directory and prints its database properties. The example demonstrates which properties require that the database be open.

import lotus.domino.*;
import java.util.Vector;
public class accessing extends NotesThread
{
  public static void main(String argv[])
    {
        accessing t = new accessing();
        t.start();
    }
  public void runNotes()
    {
    try
      {
        Session s = NotesFactory.createSession();
        DbDirectory Dir = s.getDbDirectory(null);
        Database db = Dir.getFirstDatabase(Dir.DATABASE);
// Database does not have to be open
        System.out.println
        ("DATABASE NOT OPEN");
        System.out.println
        ("Title:\t\t\t\t" + db.getTitle());
        System.out.println
        ("FileName:\t\t\t" + db.getFileName());
        System.out.println
        ("FilePath:\t\t\t" + db.getFilePath());
        System.out.println
        ("Server:\t\t\t\t" + db.getServer());
        System.out.println
        ("ReplicaID:\t\t\t" + db.getReplicaID());
        System.out.println
        ("DesignTemplateName:\t\t" + 
          db.getDesignTemplateName());
        System.out.println
        ("TemplateName:\t\t\t" + db.getTemplateName());
        System.out.println
        ("Categories:\t\t\t" + db.getCategories());
        System.out.println
        ("IsOpen:\t\t\t\t" + db.isOpen());
        System.out.println
        ("IsFTIndexed:\t\t\t" + db.isFTIndexed());
        System.out.println
        ("FTIndexFrequencey:\t\t" + db.getFTIndexFrequency());
        System.out.println
        ("IsInMultiDbIndexing:\t\t" + db.isInMultiDbIndexing());
        System.out.println
        ("IsPublicAddressBook:\t\t" + 
          db.isPublicAddressBook());
        System.out.println
        ("IsPrivateAddressBook:\t\t" + 
          db.isPrivateAddressBook());
        System.out.println
        ("IsInService:\t\t\t" + db.isInService());
        System.out.println
        ("IsPendingDelete:\t\t" + db.isPendingDelete());
        System.out.println
        ("DelayUpdates:\t\t\t" + db.isDelayUpdates());
        System.out.println
        ("SizeQuota:\t\t\t" + db.getSizeQuota());
        System.out.println
        ("MaxSize:\t\t\t" + db.getMaxSize());
        Session ps = db.getParent();
        System.out.println
        ("Parent platform:\t\t" + ps.getPlatform());
        System.out.println
        ("NotesURL\t\t\t" + db.getNotesURL());
        System.out.println
        ("HTTPURL\t\t\t" + db.getHTTPURL());
// Database must be open ...
        System.out.println("DATABASE OPEN");
        db.open();
// ... to set properties
        db.setTitle(db.getTitle() + " Redux
        System.out.println
        ("Title set to:\t\t\t" + db.getTitle());
       if (db.getCategories() == null)
          db.setCategories("Example databases");
        else
          db.setCategories(db.getCategories()
          + ";Example databases");
        System.out.println
        ("Categories set to:\t\t" + db.getCategories());
        db.setDelayUpdates(true);
        System.out.println
        ("DelayUpdates set to:\t\t" + db.isDelayUpdates());
        db.setSizeQuota(20000000);
        System.out.println
        ("SizeQuota set to:\t\t" + db.getSizeQuota());
// ... and to get these properties
        System.out.println
        ("Type:\t\t\t\t" + db.getType());
        System.out.println
        ("Created:\t\t\t" + db.getCreated().getLocalTime());
        System.out.println
        ("LastModified:\t\t\t" + 
          db.getLastModified().getLocalTime());
        System.out.println
        ("LastFTIndexed:\t\t\t" + 
          db.getLastFTIndexed().getLocalTime());
        System.out.println
        ("IsMultiDbSearch:\t\t" + db.isMultiDbSearch());
        System.out.println
        ("Size:\t\t\t\t" + (int)db.getSize() + " bytes");
        System.out.println
        ("PercentUsed:\t\t\t" + db.getPercentUsed());
        ACL acl = db.getACL();
        System.out.println
        ("ACL UniformAccess:\t\t" + acl.isUniformAccess());
        System.out.println
        ("CurrentAccessLevel:\t\t" + 
          db.getCurrentAccessLevel());
        System.out.println
        ("FolderReferencessEnabled:\t" + 
          db.getFolderReferencesEnabled());
        Vector managers = db.getManagers();
        System.out.print("Managers:\t\t\t");
        for (int i=0; i<managers.size(); i++)
            System.out.print("[" +
            (String)managers.elementAt(i) + "] ");
        System.out.println();
        System.out.println
        ("Replication Disabled:\t\t" +
        db.getReplicationInfo().isDisabled());
        Vector views = db.getViews();
        System.out.print("Views:\t\t\t\t");
        for (int i=0; i<views.size(); i++)
            System.out.print("[" +
            ((View)views.elementAt(i)).getName() + "]");
        System.out.println();
      }
    catch (Exception e)
      {
        e.printStackTrace();
      }
    }
}