B4J Question jRDC2 - response not processed

Domingo Garcia

Member
Licensed User
Thanks DonManfred, I moved the DBresult and DBcommand from Starter to Main and it resolved the error. Now I have a condition where the response is not correct or not happening. I added the code and modified it for my case:
B4X:
Sub GetChkOutId
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("sel_chk_id", Array(gtrndate, groute))
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    If j.Success Then
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        ckid = 1
        'work with result
        req.PrintTable(res)
    Else
        Log("ERROR: " & j.ErrorMessage)
    End If
    j.Release
End Sub

I step through the code and it reaches he "Wait for" line but then it ends and never reaches the j.Success if statement.
I saw the command reach the jDRC2 module and respond (It should be a no record found response) but I don't know whats happening.
jDRC2 Log:
Command: query: sel_chk_id, took: 13ms, client=192.168.1.114
Command: query: sel_chk_id, took: 228903ms, client=192.168.1.114

This second entry was when I was stepping through the code...
 

Domingo Garcia

Member
Licensed User
yes, same result in release mode. Is there a change to convert from asynch to sync a transaction. I need to assure the query to the remote DB is done and I won't be doing multiple trans simultaneously. Does anyone have an example of this working with MSSQL.
 
Upvote 0

Domingo Garcia

Member
Licensed User
I'm attaching a small test version of the app I'm using to test the jRDC2. maybe you can identify why its not responding correctly. I'm trying to read a table from a MS-SQL Server 2012 and the result should be "record not found" since a new record is created on the first request of the day. It seems to be reading the SQL Ok but its not processing the response to the client. The specs for the table are:
DB Name: pan
Table Name: CheckOut
Fields:
CheckOutDate TEXT
CheckOutId INT
Route TEXT
DriverID TEXT
UserID TEXT

in the jRDC2 module I used this line for the MSSQL jar
#AdditionalJar: jtds-1.3.1
 

Attachments

  • Checktst.zip
    15.6 KB · Views: 254
Upvote 0

Domingo Garcia

Member
Licensed User
The one on the forum you linked to is Ver 5.45.....the one I have is ver 5.5.
are there more than one download in that forum? I downloaded the one on page 1.
There is a need to have a download site with the latest version of downloads instead of the forum.
 
Last edited:
Upvote 0

Domingo Garcia

Member
Licensed User
Upvote 0

Domingo Garcia

Member
Licensed User
downloaded version (5.45 and 5.9 are the same) and now I have this error:
ResponseError. Reason: java.net.ConnectException: Failed to connect to /192.168.1.116:17178, Response:
ERROR: java.net.ConnectException: Failed to connect to /192.168.1.116:17178
on client side.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I don't see your point.

The first one is jRDC 1. The first sentence in this post:
SS-2018-02-07_08.34.05.png


The second one is an example written by one of the forum members and uses jRDC2. There is a link to jRDC2 thread inside his tutorial.

All other links are questions about jRDC2.
 
Upvote 0

Domingo Garcia

Member
Licensed User
Ok, got past the error and now the jRDC2 module responds but I'm having trouble with the information received.
I'm doing a query which should result in a no record found but the response from received (res.Rows.Size) has a 1 so when I try to extract the value it blows up because the field has Null.
I'm also not sure how to extract the value, is the "Dim Value..." line correct.

B4X:
Sub GetChkOutId
    Dim cnt As Int = 0
    If (gtrndate = strndate And groute = sroute) Then
        Return
    End If
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("sel_chk_id", Array(gtrndate, groute))
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(h As HttpJob)
    If h.Success Then
        req.HandleJobAsync(h, "req")
        Wait For (req) req_Result(res As DBResult)
        cnt = res.Rows.Size
 
        If cnt > 0 Then
            Dim Value As Int = res.Columns.Get("CheckOutID")
            Log("CheckOutId: " & Value)
            ckid = Value
        Else
            addNewChkOut
        End If
        Log("ckid:" & ckid)
        strndate = gtrndate
        sroute = groute
        req.PrintTable(res)
    Else
        Log("ERROR: " & h.ErrorMessage)
    End If
    h.Release
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Use only
B4X:
req.PrintTable(res)
after you request and see if you are getting what you think you are getting. Just because you are expecting nothing to come back, does not mean that nothing came back (and then in a format you did not expect).
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
But did you verify your result in your client app with what I asked? It's sort of hard to help without getting from you what JRDC2 returns.

Modified GetChkOutId
B4X:
Sub GetChkOutId
    Dim cnt As Int = 0
    If (gtrndate = strndate And groute = sroute) Then
        Return
    End If
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("sel_chk_id", Array(gtrndate, groute))
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(h As HttpJob)
    If h.Success Then
        req.HandleJobAsync(h, "req")
        Wait For (req) req_Result(res As DBResult)
        Log(cmd.Name)
        Log(gtrndate)
        Log(groute)
        Log(res.Rows.Size)
        req.PrintTable(res)
    Else
        Log("ERROR: " & h.ErrorMessage)
    End If
    h.Release
End Sub
Note: Code has not been tested. Typos/logic errors may need to be fixed before the code works.

What are the Log results? What is the output of req.PrintTable(res)? What are your entries in the JRDC config file for the command you issue?
 
Upvote 0
Top