Examples: compactWithOptions method

  1. This agent compacts TooBig.nsf using the options b, L, and S10.
    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
          Database db = session.getDatabase(null, "TooBig");
          if (db.isOpen())
          {
            int delta = db.compactWithOptions("bLS10");
            System.out.println("Size difference in bytes = " + delta);
          }
          else
            System.out.println("Could not open database");
    
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  2. This agent compacts TooBig.nsf using the same options.
    import lotus.domino.*;
    
    public class JavaAgent extends AgentBase {
    
      public void NotesMain() {
    
        try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
    
          // (Your code goes here) 
          Database db = session.getDatabase(null, "TooBig");
          if (db.isOpen())
          {
            int options = Database.CMPC_RECOVER_REDUCE_INPLACE +
            Database.CMPC_NO_LOCKOUT;
            int delta = db.compactWithOptions(options, "10");
            System.out.println("Size difference in bytes = " + delta);
          }
          else
            System.out.println("Could not open database");
    
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }