B4J Question JavaObject, calling the java class method.

Discussion in 'B4J Questions' started by Hanz, Aug 25, 2018.


Similar threads

B4J Code Snippet [B4X] Trust all SSL Socket
B4A Code Snippet [B4X] MQTT SSL and Self Signed Certificates
B4J Code Snippet Redirect the output to a file
B4J Tutorial jPOI to the rescue
B4J Code Snippet Multiline Labels Text Alignment
B4J Code Snippet Get Image Pixels
  1. Hanz

    Hanz Member

    Greetings everyone,

    How do you call the following code under the .RunMethod of a JavaObject:

    myDoc = collection.find(eq("i", 71)).first();

    The above code is an example given for mongodb tutorial in Java.

    I tried the following code in B4J to follow the above code:

    cursor = empCollection.RunMethod("find", _
    Array As Object(eq.RunMethod("eq", Array As Object("_id", 1))))

    cursor.RunMethod("first", Null)

    And what I have got when I run the log(cursor) is the following:

    (FindIterableImpl) com.mongodb.client.internal.FindIterableImpl@27005223

  2. stevel05

    stevel05 Expert Licensed User

    It's difficult to be certain without being able to test it but If cursor is some kind of iterable list, you seem to be nearly there.

    Try changing the second line to:

    myDoc = cursor.RunMethod("first"Null)
    I don't know what the type myDoc should be, is should be in the documentation.
    Last edited: Aug 25, 2018
  3. Hanz

    Hanz Member

    The cursor which I used is a bson document type: cursor.InitializeNewInstance("org.bson.Document", Null)

    I also tried this: cursor.InitializeStatic("com.mongodb.client.MongoCursor")

    And I'm getting the same result.
  4. Enrique Gonzalez R

    Enrique Gonzalez R Well-Known Member Licensed User

  5. Hanz

    Hanz Member

    Hey, thanks for the reply. I already resolved the issue above. As to the official library, it's based on java driver ver. 3.3. I need the java driver 3.8.x. I need the "Transactions(ACID)" and the "Change streams" features. I hope it will be updated.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice