B4J Question JRDC2 multiple database

Bernaert Dominique

Member
Licensed User
Longtime User
Does anybody have some running JRDC2 code that does this?
I've been trying to adjust the code without luck.

The client application connects to a central database (database 1).
The result from the query is the name of the database and the location of the database on the server (full path + name of the database).
All next queries should be send to the same server but with the full path + name of the database.
The queries should be executed to the database passed as a parameter.

We have more than 100 databases running on the server (each account has his own database).
That way we only need one JRDC2 server running.

Thx,
Dominique
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
See the attached example.
It is mostly untested and you will need to modify it based on your specific requirements.

The idea is to have a map of RDCConnectors instead of a single connector.
All requests should include a DBName parameter which is the connector key.
The jdbc url is set like this:
B4X:
Dim jdbc As String = config.Get("JdbcUrl")
jdbc = jdbc.Replace("$DB$", mDBName)
pool.Initialize(config.Get("DriverClass"), jdbc , config.Get("User"), _
   config.Get("Password"))

Things to consider:
1. Security - how to prevent one account from accessing database of a different account.
2. Maintenance - how to update the list of accounts preferably without resetting the server.
 

Attachments

  • jRDCMulti.zip
    4.9 KB · Views: 375
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…