Question

I'm trying to make use of Windows Search by using java Jacob library. but I'm having troubles to specify the maxRecords option to limit the number of rows get back.

I'm trying to do it by using this line:

Dispatch.put(connection, "MaxRecords", new Variant(10));

After setting up the connection:

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");
}

What am I doing wrong? There's no error on compilation but on executing I get this message:

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

And this one when accessing through my restful by URL:

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.

Everything works fine without that line.

Was it helpful?

Solution

According to the docs, the Connection object does not have a MaxRecords property. I think you'd want to set MaxRecords on a RecordSet object.

EDIT:

I haven't tried these, but would try along the following lines:

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()) {
    ...
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top