B4J Question [SOLVED] jRDC2 - how I can read the ID (type SERIAL) field from MariaDB?

Elric

Well-Known Member
Licensed User
Hello to everybody!

I'm playing with jDRC2 (thank you - it's wonderful!!!) with success.

I'm managing a DB with the field "username" as primary key.

Everything works as I expect.

BUT...

... but if in my DB on MariaDB I introduce the "ID" column, everything doesn't work anynmore.

When I introduce the column "ID", type "SERIAL" (i.e. type: "bigint(20)" and extra: "AUTO-increment"), in DBRequestManager the

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
        Log("Error reading response: " & LastException)
        Return
    End If
    Dim res As DBResult = NewObject
    res.Tag = Job.Tag
    CallSubDelayed2(mTarget, EventName & "_result", res)
End Sub

generates the following error (java.lang.RuntimeException: java.io.EOFException):

B4X:
WARNING: package com.sun.javafx.embed.swing.oldimpl not in javafx.swing
Waiting for debugger to connect...
Program started.
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
java.lang.RuntimeException: java.io.EOFException
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readType(B4XSerializator.java:314)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:374)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ReadObject(B4XSerializator.java:129)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertBytesToObject(B4XSerializator.java:99)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator$2.call(B4XSerializator.java:110)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator$2.call(B4XSerializator.java:1)
    at anywheresoftware.b4a.BA$4.run(BA.java:272)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
    at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.io.EOFException
    at java.base/java.io.DataInputStream.readByte(DataInputStream.java:271)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readByte(B4XSerializator.java:150)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:318)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readList(B4XSerializator.java:263)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:371)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readList(B4XSerializator.java:263)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:371)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readList(B4XSerializator.java:263)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readObject(B4XSerializator.java:362)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readMap(B4XSerializator.java:248)
    at anywheresoftware.b4a.randomaccessfile.B4XSerializator.readType(B4XSerializator.java:292)
    ... 11 more
Error reading response: (EOFException) java.io.EOFException

even if I don't use (at moment) the ID value in the code. The concerning error report starts from the fifth line but, however, if someone would to explain the first warning line, it is welcome! ?

The only way to make it working is to drop the column "ID" from the table.

Maybe I need to change the type value from "SERIAL" (i.e. type: "bigint(20)" and extra: "AUTO-increment")?

Thank you!
 
Top