I want to access 2 different instances on a server with ONE app.
I am running 2 x jRDC2 servers which access the different instances.
Obviously you need 2 dbrequestmanagers so that you can use 2 diffe-
rent connectionstrings. (instances are accessed via port) Something like that:
B4X:
Sub Process_Globals
Private reqManager As DBRequestManager
Private reqManager2 As DBRequestManager
Type DBResult (Tag As Object, Columns As Map, Rows As List)
Type DBCommand (Name As String, Parameters() As Object)
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
reqManager.Initialize(Me, "http://192.168.0.6:17178/rdc")
reqManager2.Initialize(Me, "http://192.168.0.6:17179/rdc")
EndIf
Activity.LoadLayout("1")
End Sub
But how do I handle the jobdone event:
B4X:
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
1. Add a "name" parameter to the DBRequestManager.Initialize method.
2. Store its value in a class_global variable.
3. Change this line to use the name parameter instead of DBRequest:
B4X:
j.Initialize("DBRequest", mTarget)
4. In JobDone check the value of JobName and call the correct DBRequestManager instance.