B4J Question JRDC2 - can't get it to work

derez

Expert
Licensed User
Longtime User
I am trying to get it working but there are too many links and I get confused. I use the jrdc2 server example after changing the config.properties file to deal with animals (comment and uncomment the existing code). Used the attached code from another link for b4a client:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        reqManager.Initialize(Me, "http://192.168.0.180:54025/rdc")
    End If
    Activity.LoadLayout("1")
'    Dim cmd As DBCommand
'    cmd.Initialize
'    cmd.Name = "create_table"
'    reqManager.ExecuteCommand(cmd,"create")
End Sub

Sub btnSelect_Click
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "select_animal"
    reqManager.ExecuteQuery(cmd, 0, Null)
End Sub


Sub JobDone(Job As HttpJob)
    If Job.Success = False Then
        Log("Error: " & Job.ErrorMessage)
    Else
        If Job.JobName = "DBRequest" Then
            reqManager.HandleJobAsync(Job, "ReqManager")
        End If
    End If
    Job.Release
End Sub

Sub ReqManager_Result(result As DBResult)
    reqManager.PrintTable(result)
End Sub

There was no table creation code so I added it but I get:
Class not found: b4a.example.main$_dbcommand, trying: b4j.example.main$_dbcommand
Class not found: b4j.example.main$_dbresult, trying: b4a.example.main$_dbresult
in B4j and B4a programs.
I don't understand what is missing.
Is my code correct ?
Can I have one example that is closed on itself with MySQL that works on my PC ?
Thanks.
 

derez

Expert
Licensed User
Longtime User
I don't understand how it works. If I set the collation in phpmyadmin to utf8_bin, does it overrides what is written in config.properties file ? Do I have to create the table from there or alter the existing table ?
Edit: After I deleted the reference to character set in the config.properties it does not send errors but I changed both DB and table to utf8_bin but I get ????? instead of Hebrew letters. Tried many other but they all show ????? (?)

Another problem - DBRequestManager is initialized with an address. If there is no communication there is no event to show it until the program crashes. I'd like to keep it alive and use it with its internal DB instead, how to do it ?
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Edit: After I deleted the reference to character set in the config.properties it does not send errors but I changed both DB and table to utf8_bin but I get ????? instead of Hebrew letters. Tried many other but they all show ????? (?)
Try to create a new database with a new table and make sure to set the collate to utf8.

Another problem - DBRequestManager is initialized with an address. If there is no communication there is no event to show it until the program crashes. I'd like to keep it alive and use it with its internal DB instead, how to do it ?
Please start a new thread for this.
 
Upvote 0

derez

Expert
Licensed User
Longtime User
upload_2017-3-14_10-1-15.png


upload_2017-3-14_10-2-46.png



upload_2017-3-14_10-1-33.png


A new DB and table defined but the result is the same :(.
I'm working with a b4j client, is it possible that the output to the server is not correct ? It works fine with a SQLITE DB.
 
Upvote 0

derez

Expert
Licensed User
Longtime User
There are two collations that need to be set. One for the database and one for the table.

Try to get the value in the client. Maybe the problem is in phpmyadmin.

the top picture is of the database, the second of the table.
It is not a problem of the phpmyadmin because I get the same in my logs.
I can't get the text from the DBrequestmanager.
 
Upvote 0
Top