我正在尝试使用 java Jacob library. 来使用 Windows 搜索但我无法指定 maxRecords
限制返回行数的选项。
我正在尝试使用这一行来做到这一点:
Dispatch.put(connection, "MaxRecords", new Variant(10));
设置连接后:
connection = new Dispatch("ADODB.Connection");
Dispatch.call(connection, "Open", "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';");
//-------> error in the following line <-------
Dispatch.put(connection, "MaxRecords", new Variant(10));
results = Dispatch.call(connection, "Execute",
"SELECT System.ItemName, System.DateModified " +
"FROM SystemIndex " +
"WHERE Directory='file:C:/my/folder/path' AND Contains('a')").toDispatch();
while (!Dispatch.get(results, "EOF").getBoolean()) {
Dispatch fields = Dispatch.get(results, "Fields").toDispatch();
String filename = Dispatch.get(Dispatch.call(fields, "Item", new Integer(0)).toDispatch(), "Value").toString();
String filedate = Dispatch.get(Dispatch.call(fields, "Item", new Integer(1)).toDispatch(), "Value").toString();
list.put(filename, filedate);
Dispatch.call(results, "MoveNext");
}
我做错了什么? 编译时没有错误,但执行时我收到此消息:
com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: MaxRecords
Description: 80020007 / No named arguments.
...
Internal Server Error (500) - The server encountered an unexpected condition which prevented it from fulfilling the request
通过 URL 访问我的 Restful 时的这个:
Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request You can get technical details here. Please continue your visit at our home page.
没有那条线一切正常。
最佳答案
根据文档,Connection对象没有 MaxRecords 属性。我想你想在RecordSet上设置MaxRecords对象。
编辑:
我还没有尝试过这些,但会尝试以下方式:
connection = new Dispatch("ADODB.Connection");
Dispatch.call(connection, "Open", "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';");
String sql = "SELECT System.ItemName, System.DateModified " +
"FROM SystemIndex " +
"WHERE Directory='file:C:/my/folder/path' AND Contains('a')"
recordSet = new Dispatch("ADODB.Recordset");
Dispatch.put(recordSet, "MaxRecords", new Variant(10));
Dispatch.call(recordSet, "Open", sql, connection);
while (!Dispatch.get(recordSet, "EOF").getBoolean()) {
...
}
关于java - 使用 Java Jacob 库设置 MaxRecords,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21754688/