B4J Library [class] jRDC - B4J implementation of RDC (Remote Database Connector)

Status
Not open for further replies.
jRDC version 2 is available here: https://www.b4x.com/android/forum/t...ation-of-rdc-remote-database-connector.61801/

Please start with this thread if you are not familiar with RDC: Remote Database Connector (RDC) - Connect to any remote DB

RDC was implemented before B4J was available. It was implemented in Java.
jRDC is a port of RDC server to B4J.
The main advantage of jRDC over RDC is that you can modify the source code. For example you can easily add support for SSL or connect to multiple databases.
The performance of both servers is the same.
Note that B4J creates executable jars so you can start the server with a double click or from the command line with:
B4X:
java -jar jRDC.jar

There are some differences between the behavior and configuration of jRDC and RDC:
  • On the client, the server link should end with /rdc. For example:
    B4X:
    reqManager.Initialize(Me, "http://192.168.0.6:17178/rdc")
  • You need to set the jdbc jar with the #AdditionalJar attribute (on the server). There is no jdbc_driver folder.
  • jRDC always returns 0 for the affected rows fields in batch requests.
From the client side you just need to add /rdc to the link and it should work.

There is another difference related to the way nulls are handled. It shouldn't be a problem with new jdbc drivers.

jRDC v1.00 is attached. It fixes an issue related to blobs.
 

Attachments

  • jRDC.zip
    4.8 KB · Views: 1,375
Last edited:

marcick

Well-Known Member
Licensed User
Longtime User
Hi.
I was thinking to replace the actual RDC with this one. The goal is to add in each RDC command a custom text parameter that the server shows in the console. This would help me to identify the customers just watching the console.
First question is .. I can't see the console ... which is the best way to implement it ?
Second difficulties is how to manage the custom text, but I think I should look the SUb "LoadSQLCommands" and understant it.
 

marcick

Well-Known Member
Licensed User
Longtime User
oh, understood, so anything is added as log in B4J then is showed in the console. Very good, thanks
Marco
 

marcick

Well-Known Member
Licensed User
Longtime User
Some troubles ...
this is the code B4A side

B4X:
reqManager1.Initialize(Me, "http://100.100.100.100:17178/rdc")
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = "RDC_Test"
    cmd.Parameters = Array As Object(Null)
    reqManager1.ExecuteQuery(cmd, 0, "tag1")

in config.properties I have
B4X:
sql.RDC_Test = SELECT COUNT(*) FROM `records`
But I get this error:

B4X:
(SQLException) java.sql.SQLException: Parameter index out of range (1 > number o
f parameters, which is 0).
Command: , tool: 0ms, client=82.60.232.57

Where I'm wrong ?
The same identical code (except for the "/rdc" suffix in reqmanager.initialize) is working on the "old" RDC
 

marcick

Well-Known Member
Licensed User
Longtime User
Perfect !

Now, when I'm at this line in SUB Handle of RDCHandler module:

B4X:
 Log($"Command: ${q}, tool: ${DateTime.Now - start}ms, client=${req.RemoteAddress}"$)

How to retrieve all the parameters of the request ?
 

marcick

Well-Known Member
Licensed User
Longtime User
Me again ..
running the jar from the command line I see a log file is created that contains strings like:

B4X:
82.60.232.57 -  -  [22/Oct/2015:11:40:38 +0000] "POST /rdc?method=query HTTP/1.1" 200 - "-" "-"

Is it possible to avoid this log or eventually customize it ?
 

Anser

Well-Known Member
Licensed User
Longtime User
There is another difference related to the way nulls are handled. It shouldn't be a problem with new jdbc drivers.
Will this break my existing B4A code?

In my code, I have many lines that check for Null For eg.
B4X:
If records(result.Columns.Get("Activity_DateTime")) = Null Then

If records(result.Columns.Get("Bill_Amt")) = Null Then
So do I have to take care of all that ?

From the client side you just need to add /rdc to the link and it should work.

If the change in my B4A code is minimal then, I am planning to move from RDC to jRDC

Regards
Anser
 

incendio

Well-Known Member
Licensed User
Longtime User
Better to move to jRDC.

I have seen its features & 1 is really obvious, security.

With RDC, user name & password,url, sql commands, etc, stored on config file with is very easy to read.
With jRDC, you can embedded in jar file or on any encrypted file.
 
Status
Not open for further replies.
Top