【问题标题】:How to access domino desiger DB by java Agent in lotus notes?如何通过 Lotus Notes 中的 java Agent 访问 domino desiger DB?
【发布时间】:2015-01-22 17:04:23
【问题描述】:

您好,我是 Lotus Script 的新手

我想运行一个访问数据库的 Java 代理来读取表单存储的视图。

我更新了代码

下面是我的代码:

public class JavaAgent extends AgentBase {

    public void NotesMain() {

      try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
          // (Your code goes here) 
          Database db = agentContext.getCurrentDatabase();
          View view = db.getView("PetView");
          view.setAutoUpdate(false);
          view.setAutoUpdate(false);
          ViewEntryCollection vec = view.getAllEntries();
          System.out.println("Parent is " + 
            vec.getParent().getName());
          System.out.println("Number of entries = " + 
            vec.getCount());
          ViewEntry tmpentry;
          ViewEntry entry = vec.getFirstEntry();
          while (entry != null) {
            System.out.println("Entry is at position " + 
            entry.getPosition('.'));
            tmpentry = vec.getNextEntry();
            entry.recycle();
            entry = tmpentry;
          }
      } catch(Exception e) {
          e.printStackTrace();
       }
   }
}

我的调试控制台 O/P 是:

    Parent is PetView
Number of entries = 8
Entry is at position 1
Entry is at position 2
Entry is at position 3
Entry is at position 4
Entry is at position 5
Entry is at position 6
Entry is at position 7
Entry is at position 8

如果我错了,请纠正我

谢谢。

【问题讨论】:

    标签: lotus-domino lotusscript lotus domino-designer-eclipse


    【解决方案1】:

    要获取本地数据库,只需使用不带服务器名的 getdatabase。

    设置 db = notessession.getdatabase("", "path\dbname.nsf")

    【讨论】:

      【解决方案2】:

      您的代码甚至没有尝试访问视图。您正在访问包含所有文档的集合。

      要访问视图,您只需要这样的东西:

      View v = tempDb.getView("theViewNameOrAliasGoesHere");
      

      【讨论】:

        猜你喜欢
        • 2014-02-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多