B4J Question JRDC2 request does not work

marcick

Well-Known Member
Licensed User
Longtime User
I follow the tutorial and can't understand where I'm wrong
Code is running on a B4J/MySql server that need to ask data to another B4J/MySql server.
B4J 6.30
Tried both in debug and release

This works:

B4X:
    Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("GetCredit", Null)
req.ExecuteQuery(cmd, 0, "tag1")
wait for jobdone(j As HttpJob)
If J.Success = True Then

I have the JobDone event and I can see the result

But this one should be better
Remote server receives the query, but I never have the JobDone event. Why ?

B4X:
    Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("GetCredit", Null)
Wait For (req.ExecuteQuery(cmd, 0, "tag1")) JobDone(j As HttpJob)
If J.Success = True Then
 

DonManfred

Expert
Licensed User
Longtime User
This works
why not just use it this way if it works?

I guess that
B4X:
req.ExecuteQuery(cmd, 0, "tag1")
does not return a Senderfilter wjich can be used in your wait for call.
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
I can have multiple parallel requests of this sub, so I was thinking (but may be I'm wrong) the second variant is better.
Or they have identical behaviuor ?

@tigrot: I'll see the log later
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Technically, with Wait For you should not need to use tags anymore to discern your jobs (instead of passing on "tag1", pass on Null). I use the second version of your posted code snippet without issues, even with 6.30. To make your first snippet equivalent to the second it should be (I'm removing the tag here)
B4X:
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("GetCredit", Null)
Dim j As HttpJob = req.ExecuteQuery(cmd, 0, Null)
Wait For (j) JobDone(j As HttpJob)
If j.Success = True Then

Code example that uses your second code snippet can be found here: https://www.b4x.com/android/forum/threads/jrdc2-client-example-using-modded-jrdc2.85581/
Look at the method ExecuteQuery in the jRDC2Utils module of that project.
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
Thanks everybody.
Yes, the problem was DBRequestManager not updated.
Now it works.
Bye :)
 
Upvote 0
Top