我试图通过使用爪哇雅各布图书馆。来使用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:遇到COM异常: 在调用: MaxRecords时 描述: 80020007 /无命名参数。 ..。 内部服务器错误(500) -服务器遇到意外情况,无法满足请求
在通过我的restful访问时:
内部服务器错误 服务器遇到了一个意外的情况,无法满足您可以获得技术细节这里的请求。请继续访问我们的主页。
没有那条线一切都很好。
发布于 2014-02-21 12:28:12
根据文档,连接对象没有MaxRecords属性。我认为您会希望在一个MaxRecords对象上设置RecordSet。
编辑:
我还没有试过这些,但是我会按照以下的思路来尝试:
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()) {
...
}https://stackoverflow.com/questions/21754688
复制相似问题