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,057
Last edited:

incendio

Well-Known Member
Licensed User
I got error when trying to run it on Raspberry Pi2

Here is the error :
java.lang.RuntimeException: Cannot parse: null as boolean
at anywheresoftware.b4a.BA.parseBoolean(BA.java:273)
at anywheresoftware.b4a.BA.ObjectToBoolean(BA.java:342)
at b4j.example.rdcconnector._initialize(rdcconnector.java:90)
at b4j.example.main._appstart(main.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccesjava:57)

Jave ver on Raspberry is "1.7.0_40"
 

Roycefer

Well-Known Member
Licensed User
Check the RDConnector.Initialize method. It says you're trying to parse a Null as a Boolean, which it can't do.
 

incendio

Well-Known Member
Licensed User
Thanks for your replied.

Found the problem. It was in the config file. Missing the line Debug=true which is called in the Initialize method.
 

Bladimir Carrillo

Member
Licensed User
I tested my last app with jRDC (it's running perfectly with RDC) but have the following:
- ExecuteQuery (with SELECT) works well and return the correct results.
- ExecuteCommand (with INSERT or UPDATE) apparently successful execution returns (to jobDone Sub) but the database does not reflect changes.

May be a bug?
 

Bladimir Carrillo

Member
Licensed User
Are you 100% that the updates are not persisted? Try to create a new table and insert some data.
An exception will be thrown if the JDBC driver reports any error.
Yes Erel, when I stop jRDC and enable RDC again (with same configuration config.properties file) then works fine.
 

Bladimir Carrillo

Member
Licensed User
You will need to debug it. See which command is not working. RDC and jRDC are almost identical.

jRDC Debugging results:
Tests with oralce jdbc driver (ojdbc6.jar)

TEST 1

- Server runing on B4J ide / Debug(rapid) mode
- Client runing installed app
- Requests from client:
* SELECT. All OK
* UPDATE or INSERT. Connection to server crashes and any type of requests works (nor SELECT nor INSERT nor UPDATE), but continued running jRDC application on IDE. Any error is displayed on B4J ide.

TEST 2
- Server runing jRDC.jar
- Client runing on B4A ide / Debug(rapid) mode
- Requests from client:
* SELECT. All OK
* UPDATE or INSERT. "java.net.SocketTimeoutException" error on Job.ErrorMessage. Connection to server do not crashes and SELECT requests only works.
 
Status
Not open for further replies.
Top