Xpages-Java库-NotesFactory.CreateSession中出现错误
首先,扩展库还不能用于某些服务器。我想比较数据库所有副本中的文档数。我想在网页上显示同样的内容。因此,我正在遍历catalog.nsf条目。这是代码。问题是,它无法创建会话。代码如下:Xpages-Java库-NotesFactory.CreateSession中出现错误,xpages,Xpages,首先,扩展库还不能用于某些服务器。我想比较数据库所有副本中的文档数。我想在网页上显示同样的内容。因此,我正在遍历catalog.nsf条目。这是代码。问题是,它无法创建会话。代码如下: package com.apse.replication; import java.util.*; import lotus.domino.*; /** * @author Arun Agnihotri * */ @SuppressWarnings("unchecked") public class Re
package com.apse.replication;
import java.util.*;
import lotus.domino.*;
/**
* @author Arun Agnihotri
*
*/
@SuppressWarnings("unchecked")
public class ReplicationCountMismatches
{
Session s = null;
Database catDb = null;
View catView = null;
Document catDoc = null;
DocumentCollection catCol = null;
Vector v;
String key;
//hashmap object to hold the database replica id as key and document count as value
Hashtable<String, Integer> dbTable = new Hashtable<String, Integer>();
//array to hold server names
String serverNames[] = {"Server1","Serevr2","Server3"};
public DocumentCollection GetMismatchedReplicas(){
//we'll loop through catalog database of every server and update the hashmap
try{
for (int i=0;i<serverNames.length;i++){
s = NotesFactory.createSession(); //this is WHERE I RECEIVE ERROR
catDb = s.getDatabase(serverNames[i], "catalog.nsf");
catView = catDb.getView("Applications\\By Title");
catDoc = catView.getFirstDocument();
while(catDoc!=null){
v = s.evaluate("@Text(ReplicaID;\"*\")", catDoc);
key=v.firstElement().toString();
if (i==0){
//first catalog being scanned.. put all key-value pairs in HashTable
dbTable.put(key, catDoc.getItemValueInteger("DbNumDocuments"));
}
else{
if (!dbTable.containsKey(key)){
dbTable.put(key, catDoc.getItemValueInteger("DbNumDocuments"));
}
else{
if ((Integer) dbTable.get(key) != catDoc.getItemValueInteger("DbNumDocuments")){
catCol.addDocument(catDoc);
}
}
}
catDoc = catView.getNextDocument(catDoc);
}
}
}
catch(Exception e){
e.printStackTrace();
}
return catCol;
}
}
package com.apse.replication;
导入java.util.*;
导入lotus.domino.*;
/**
*@作者阿伦·阿格尼霍特里
*
*/
@抑制警告(“未选中”)
公共类复制计数不匹配
{
会话s=null;
数据库catDb=null;
视图catView=null;
文档catDoc=null;
DocumentCollection catCol=null;
向量v;
字符串键;
//hashmap对象,将数据库副本id作为键,文档计数作为值
Hashtable dbTable=新的Hashtable();
//用于保存服务器名称的数组
字符串serverNames[]={“Server1”、“Serevr2”、“Server3”};
公共文档集合GetMismatchdReplicas(){
//我们将遍历每个服务器的目录数据库并更新hashmap
试一试{
对于(inti=0;i),当Java代码在XPages上下文中运行时,应该使用Jsf会话
import com.ibm.xsp.extlib.util.ExtLibUtil;
...
Session s = ExtLibUtil.getCurrentSession();
如果要在其上执行代码的服务器没有ExtLibUtil,则可以创建自己的JsfUtil库,如图所示