1

我正在尝试通过使用java Jacob 库来使用 Windows Search。但我无法指定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访问时:

内部服务器错误

服务器遇到了一个意外情况,导致它无法完成请求。您可以在此处获取技术详细信息。请继续访问我们的主页。

没有那条线,一切都很好。

4

1 回答 1

1

根据文档,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()) {
    ...
}
于 2014-02-21T12:28:12.450 回答