B4J Question jRDC, How to connect to multiple database?

incendio

Well-Known Member
Licensed User
Longtime User
Hi guys,

I need a help, how to configure jRDC to connect to multiple database.

Thanks in advance.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You will need to understand how the code is built and change it a bit. It is quite simple.

Replace rdcConnector1 with rdcConnectorA and rdcConnectorB.
Each one of them will point to a different database (you will need to take care of loading the correct configuration file).

Now in RDCHandler add this to Class_Globals
B4X:
private connector as RDCConnector
private connectors As Map = CreateMap("a": Main.rdcConnectorA, "b": Main.rdcConnectorB)

You will need to add an additional parameter to the query (together with the method parameter). Lets call it database.
B4X:
Dim method As String = req.GetParameter("method")
connector = connectors.Get(req.GetParameter("database"))
The last step is to change the references to Main.rdcConnector1 with connector.
 
Upvote 0
i follow this instruction but, how about configuration file ? should i create 2 config file ? if yes, how i call these config file ?
also about main, should i create srvr1 and srvr2 to define server port ?
and about testhandler should i create connector again like in testhandler ?

thx alot
 
Last edited:
Upvote 0
Top