Android Question [B4X] jRDC2 "Error reading response: (EOFException) java.io.EOFException"

irda

Member
Licensed User
Longtime User
Hello comunity.

I'm trying to retrieve an image (6.6KB) from the database (MySQL) with jRDC2 (thanks Erel!) and everything seems to work fine until I get to the HandleJobAsync function, where Success=false and show the menssage: "Error reading response: (EOFException) java.io.EOFException"

The query seems to be executed correctly as this message appears on the java server: "Command: query: GetAPwithLogin, took: 1805ms, client=192.168.1.132"

I have tried with blob and longblob types but the result is the same. From what I've read in the forums, the blob type is supported by jRDC2, isn't it?

Thanks for your help
 

DonManfred

Expert
Licensed User
Longtime User
Hiding 100% of the Code you are using is of zero help for us to help you.
If success is false then you can not get any result. You have to check why the request does not work.
 
Upvote 0

irda

Member
Licensed User
Longtime User
Hello.
I can't find the error but I do find the solution. Everything seems correct but the following happens depending on the sentence that I use.
* sql.data=SELECT * FROM clients WHERE id = ? ==> Error
* sql.data=SELECT Logo FROM clients WHERE id = ? ==> OK
The data table only contains an id (numeric), a logo (blob) and various text fields.
 
Upvote 0

irda

Member
Licensed User
Longtime User
Hello.

After two weeks of testing and testing, repeating all the steps in the tutorial, I can't move forward

I keep getting the same error with different queries, it doesn't work correctly for me and I always have the error in the same place:

File: DBRequestManager.bas


B4X:
Public Sub HandleJobAsync(Job As HttpJob, EventName As String)
    Dim ser As B4XSerializator
    Dim data() As Byte = Bit.InputStreamToBytes(Job.GetInputStream)
    ser.ConvertBytesToObjectAsync(data, "ser")
    Wait For (ser) ser_BytesToObject (Success As Boolean, NewObject As Object)
    If Success = False Then         'ALWAYS FALSE
        Log("Error reading response: " & LastException)
        Return
    End If
    Dim res As DBResult = NewObject
    res.Tag = Job.Tag
    CallSubDelayed2(mTarget, EventName & "_result", res)
End Sub

B4A LOG: Error reading response: (EOFException) java.io.EOFException

B4J jRDC LOG: Command: query: VerifyLogin took 2157ms, client=192.168.1.100

The jRDC server seems to be working fine with queries because no error messages appear.

The functions that perform the queries are:

B4X:
Public Sub GetRecord (Command As String, id As Int)As ResumableSub
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand(Command, Array(id))
    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)
        'work with result
        req.PrintTable(res)
    Else
        Log("ERROR: " & j.ErrorMessage)
    End If
    j.Release
End Sub

Public Sub GetRecord2 (Command As String, parameters() As String) As ResumableSub
    Dim Answer As Map
    Answer.Initialize
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand(Command, parameters)
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    Answer.Put("ResultadoOK", j.Success)
    If j.Success Then
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(Res As DBResult)
        'work with result
        req.PrintTable(Res)
        Answer.Put("Message","Data have been read successfully")
    Else
        Log("ERROR: " & j.ErrorMessage)
        Answer.Put("Error", j.ErrorMessage)
    End If
    j.Release
    Answer.Put("Datos",Res)
    'req.PrintTable(Res)
    Return Answer
End Sub


B4X:
        Dim Parametros() As String = Array As String(param1, param2)
        Wait For(GetRecord("data", Parametros)) Complete (Answer As Map)
        
        If Answer.Get("ResultadoOK") Then
        '    Dim l As List
            Dim rs As DBResult
            rs = Answer.Get("Datos")
            ...

and the config.properties query

sql.data=SELECT * FROM clients WHERE id = ? and code = ?


Thanks
 
Upvote 0

irda

Member
Licensed User
Longtime User
Hi everyone.
I finally found the problem and the solution.
The application shows the Error reading response: (EOFException) java.io.EOFException error when the "id" field is involved in the sql statement, which is of type bigint, autoincrement.
I am using MySQL. I had to change the bigint field to int and all the SQL queries have already worked correctly.

I hope this information is useful to people. Thanks
 
Upvote 0
Top