Android Question Problem with jRDC2 - Connect to remote databases tutorial

Paolodc

Member
Client: Main module:
Sub Process_Globals
    Type DBResult (Tag As Object, Columns As Map, Rows As List)
     Type DBCommand (Name As String, Parameters() As Object)
    Private const rdcLink As String = "'http://192.168.43.144:17178/example"'http://
  [QUOTE][/QUOTE]  'pcHotspot: 192.168.137.147
    'deviceHotspot: 192.168.43.144
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private spnrCountry As Spinner
    Private spnrCity As Spinner
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    GetPaese
    'CreateRequest
End Sub
Sub GetPaese
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("seleziona_tutto_paese", Null)
    Log(req & cmd)
    Wait For (req. ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)'there is an error
    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

Sub spnrCountry_ItemClick (Position As Int, Value As Object)
   
End Sub

Sub spnrCity_ItemClick (Position As Int, Value As Object)
   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub CreateRequest As DBRequestManager
    Dim req As DBRequestManager
    req.Initialize(Me, rdcLink)
    Log(req.IsInitialized)
    'Log(req)
    Return req
End Sub

Sub CreateCommand(Name As String, Parameters() As Object) As DBCommand
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = Name
    'Log(cmd)
    If Parameters <> Null Then cmd.Parameters = Parameters
    Return cmd
End Sub
 

Attachments

  • errorlines.txt
    2.6 KB · Views: 132

DonManfred

Expert
Licensed User
Longtime User
Private const rdcLink As String = "'http://192.168.43.144:17178/example"

true
[httputils2service=null, link='[URL]http://192.168.43.144:17178/example[/URL], main=null
, mtarget=class b4a.example.main, starter=null, version=2.0
][IsInitialized=true, Name=seleziona_tutto_paese, Parameters=[Ljava.lang.Object;@a3735f4
]
a
Error occurred on line: 46 (HttpJob)
java.lang.IllegalArgumentException: Expected URL scheme 'http' or 'https' but no colon was found

Remove the ' in the URL
B4X:
Private const rdcLink As String = "http://192.168.43.144:17178/example"
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Unless you have changed the source code of the jRDC2 server, your rdcLink string should be more like
B4X:
Private const rdcLink As String = "http://192.168.43.144:17178/rdc"
Note:
Out of the box (unmodified), you'll have two URLs set up for your jRDC server. Both URLs will start with
B4X:
http://xxx.xxx.xxx.xxx:yyyy
Where xxx.xxx.xxx.xxx is the IP address of the machine you are running the jRDC2 server on and yyyy is the port number, which defaults to 17178 (the source the configuration file would have to be changed to use a different port number).
Then you have two "pages" set up that can be accessed:
a) /test
This can be accessed via a browser to see if the jRDC2 server is connecting properly to your database
and
b) /rdc
This is accessed via the DBRequestManager class module to upload/download serialized data from the jRDC2 server[/code]
 
Upvote 0
Top