Java 由于空对象,IBM Lotus Notes 从视图中检索数据在中间失败
Java IBM Lotus Notes retrive data from view fails in the middle due to null object
我正在尝试使用 java 程序从 Lotus Notes 数据库视图中检索数据。下面是我的代码:
int resultsCount = view.getEntryCount();
print("Results found in view = " + resultsCount);
Document doc = view.getFirstDocument();
if (doc != null) {
int count = 1;
while (count <= resultsCount) {
count++;
try {
doc = view.getNextDocument(doc);
if (doc == null) {
print("Record " + count + " error. Null object.");
}
} catch (NotesException e) {
print("Record " + count + " error. Exception.");
}
}
}
else {
print("Record " + count + " error. Null object.");
}
我得到以下结果:
在视图中找到的结果 = 1567
记录 866 错误。空对象。
为什么在数据库视图中实际存在 1567 条记录时发现空文档?
我该如何恢复以获取其余记录,因为 view.getNextDocument(doc) 在发生这种情况后因 Notes Exception 而失败。
已使用
修复
int resultsCount = view.getAllEntries().getCount();
而不是
int resultsCount = view.getEntryCount();
使用 view.getAllEntries().getCount() returns 实际条目计数为 866。我不确定 view.getEntryCount() returns 是什么。但这绝对不是实际的文档数。
编辑:
如 XPages getEntryCount vs getAllEntries().getCount() view.getEntryCount() 中所述,包括复制和保存冲突。因此要获得实际记录数需要使用 view.getAllEntries().getCount()
我正在尝试使用 java 程序从 Lotus Notes 数据库视图中检索数据。下面是我的代码:
int resultsCount = view.getEntryCount();
print("Results found in view = " + resultsCount);
Document doc = view.getFirstDocument();
if (doc != null) {
int count = 1;
while (count <= resultsCount) {
count++;
try {
doc = view.getNextDocument(doc);
if (doc == null) {
print("Record " + count + " error. Null object.");
}
} catch (NotesException e) {
print("Record " + count + " error. Exception.");
}
}
}
else {
print("Record " + count + " error. Null object.");
}
我得到以下结果:
在视图中找到的结果 = 1567
记录 866 错误。空对象。
为什么在数据库视图中实际存在 1567 条记录时发现空文档?
我该如何恢复以获取其余记录,因为 view.getNextDocument(doc) 在发生这种情况后因 Notes Exception 而失败。
已使用
修复int resultsCount = view.getAllEntries().getCount();
而不是
int resultsCount = view.getEntryCount();
使用 view.getAllEntries().getCount() returns 实际条目计数为 866。我不确定 view.getEntryCount() returns 是什么。但这绝对不是实际的文档数。
编辑:
如 XPages getEntryCount vs getAllEntries().getCount() view.getEntryCount() 中所述,包括复制和保存冲突。因此要获得实际记录数需要使用 view.getAllEntries().getCount()