B4J Question Error on JRDC2

microbox

Active Member
Licensed User
Longtime User
I have this message after compiling "jRDC is running (version = 2.1)" but when trying to open a browser(chrome) and typing localhost:17178 it says Error 404.
This what I have in the config.properties
B4X:
#DATABASE CONFIGURATION
DriverClass=com.mysql.jdbc.Driver
JdbcUrl=jdbc:mysql://localhost/test?characterEncoding=utf8
User=root
Password=
#Java server port
ServerPort=17178
I have xampp installed on my machine.
Can anybody kindly tell what I'm doing wrong?

Thanks,
joe
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Seems right

but solely localhost:17178 its not enough, you need:
localhost:17178/test

And for the device access.
localhost:17178/handler
(if you run this one on browser, it may throw error too)
 
Upvote 0

microbox

Active Member
Licensed User
Longtime User
Thanks Enrique got it now :). But I'm stuck with another error when trying to access with the client application
B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
     Private reqManager As DBRequestManager
   Type DBResult (Tag As Object, Columns As Map, Rows As List)
   Type DBCommand (Name As String, Parameters() As Object)
    Private btnSelect As Button
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   
     reqManager.Initialize(Me, "10.211.55.4/rdc")
  
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.Show
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


Sub btnSelect_Action
   Dim cmd As DBCommand
   cmd.Initialize
   cmd.Name = "RDC_Test"
   Log(cmd)
   reqManager.ExecuteQuery(cmd, 0, Null)
End Sub

When I click the button I get this error
B4X:
[IsInitialized=true, Name=RDC_Test, Parameters=[Ljava.lang.Object;@62eaf7d9
]
httpjob._postbytes (java line: 228)
java.lang.IllegalArgumentException: unexpected url: 10.211.55.4/rdc?method=query2
    at com.squareup.okhttp.Request$Builder.url(Request.java:157)
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpRequest.InitializePost2(OkHttpClientWrapper.java:419)
    at b4j.example.httpjob._postbytes(httpjob.java:228)
    at b4j.example.dbrequestmanager._sendjob(dbrequestmanager.java:203)
    at b4j.example.dbrequestmanager._executequery(dbrequestmanager.java:71)
    at b4j.example.main._btnselect_action(main.java:110)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.BA$2.run(BA.java:165)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:745)

This is what I have in the config.properties
B4X:
#DATABASE CONFIGURATION
DriverClass=com.mysql.jdbc.Driver
JdbcUrl=jdbc:mysql://localhost/sensordb?characterEncoding=utf8
User=root
Password=
#Java server port
ServerPort=17178

sql.RDC_Test = SELECT COUNT(*) FROM sensorread
Any help is greatly appreciated.
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
I believe that it is because of this:

B4X:
"10.211.55.4/rdc"

should be:

B4X:
"http://10.211.55.4/rdc"
 
Last edited:
Upvote 0

microbox

Active Member
Licensed User
Longtime User
Almost there...
To query data from my database table I have this in the config.properties
B4X:
sql.RDC_Test = SELECT * FROM sensorread
and to execute it I have this event
B4X:
Sub btnSelect_Action
   Dim cmd As DBCommand
   cmd.Initialize
   cmd.Name = "RDC_Test"
   Log(cmd)
   reqManager.ExecuteQuery(cmd, 0, Null)
End Sub
(It should get the data)...but that's what I think. I'm getting this log.
B4X:
(
[IsInitialized=true, Name=RDC_Test, Parameters=[Ljava.lang.Object;@259027fa
]
HTTP Job Done. Job Name: DBRequest, Job Result: false
Error: Not Found
 
Last edited:
Upvote 0

microbox

Active Member
Licensed User
Longtime User
I have the RDC_Test in my config.properties
B4X:
#DATABASE CONFIGURATION
DriverClass=com.mysql.jdbc.Driver
JdbcUrl=jdbc:mysql://localhost/sensordb?characterEncoding=utf8
User=root
Password=
#Java server port
ServerPort=17178
sql.RDC_Test = SELECT id,date,time FROM sensorread
sql.select=select id,date,time from sensorread
but still I am not able to make it work :confused:
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
From what i can see in your code, there is no problem anywhere, maybe I am missing something.

Could you upload both sides? Client and server so I can see in detail
 
Upvote 0

microbox

Active Member
Licensed User
Longtime User
Hi, kindly check attached file.
I will try to setup it to another machine.

Thanks for the time.
 

Attachments

  • jRDC.zip
    53.6 KB · Views: 275
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
hi microbox!

So far, so good, my only observation is:

B4X:
'Client side
    reqManager.Initialize(Me, "http://127.0.0.1:17178/rdc") ' the port was missing

i am still testing the code!
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
okey, here in my enviroment

i tried both of this:

B4X:
sql.RDC_Test = SELECT id,date,time FROM sensorread
sql.select=select id from sensorread

and worked without any problem.

When you click in your button, what log appears in the server side?
 
Upvote 0
Top