1

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.

Community
  • 1
  • 1
Alvaro
  • 40,778
  • 30
  • 164
  • 336

1 Answers1

1

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()) {
    ...
}
beny23
  • 34,390
  • 5
  • 82
  • 85
  • Yeah, so how could I do it? – Alvaro Feb 21 '14 at 12:42
  • I've created the `Dispatch recordSet;` and then adding the two lines you suggested ([like this](http://pastebin.com/kUh1ith5)) but It doesn't seem to work. Getting the error `java.lang.IllegalArgumentException: Can't pass in null Dispatch object`. – Alvaro Feb 21 '14 at 15:40
  • Unfortunately, I can't access pastebin (corporate proxy), I'll have a look from home later. – beny23 Feb 21 '14 at 15:44
  • Sorry, [here the initialization](http://pastebin.com/G8wXabS6) of the variables as well. – Alvaro Feb 21 '14 at 15:45
  • which one can you access so that I can share code with you. – Alvaro Feb 21 '14 at 15:45
  • You are still using results in your while loop when you should be using recordSet. – beny23 Feb 21 '14 at 18:38