我正试图通过使用javaJacob库来利用WindowsSearch。但是我在指定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:遇到com异常:
在调用:MaxRecords时
描述:80020007/没有命名参数
内部服务器错误(500)-服务器遇到意外情况,无法完成请求
当通过我的restful通过URL:访问时
内部服务器错误
服务器遇到意外情况,无法完成请求你可以在这里获得技术细节。请继续访问我们的主页。
没有那一行,一切都很好。
根据文档,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()) {
...
}