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

Discussion in 'B4J Libraries & Classes' started by Erel, Oct 13, 2015.

Thread Status:
Not open for further replies.
  1. Erel

    Erel Administrator Staff Member Licensed User

    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:
    Code:
    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:
      Code:
      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.
     

    Attached Files:

    Last edited: Dec 29, 2015
    LucaMs, Mark Turney, cimperia and 6 others like this.
  2. marcick

    marcick Well-Known Member Licensed User

    Great !
     
  3. marcick

    marcick Well-Known Member Licensed 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.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You will see the logs when:
    1. Run it from the IDE.
    2. Run it from the command line with: java -jar <your jar>
     
  5. marcick

    marcick Well-Known Member Licensed User

    oh, understood, so anything is added as log in B4J then is showed in the console. Very good, thanks
    Marco
     
  6. marcick

    marcick Well-Known Member Licensed User

    Some troubles ...
    this is the code B4A side

    Code:
    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
    Code:
    sql.RDC_Test = SELECT COUNT(*) FROM `records`
    But I get this error:

    Code:
    (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
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    You are sending a single parameter (with the value of null) and the command doesn't expect any parameter.

    Remove the line that sets cmd.Parameters or change it to:
    Code:
    cmd.Parameters = Array As Object()
     
  8. marcick

    marcick Well-Known Member Licensed User

    Perfect !

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

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

    How 
    to retrieve all the parameters of the request ?
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Go over the code you will see where the parameters are extracted.
     
  10. marcick

    marcick Well-Known Member Licensed User

    Thanks Erel, found how to do
     
    Erel likes this.
  11. marcick

    marcick Well-Known Member Licensed User

    Me again ..
    running the jar from the command line I see a log file is created that contains strings like:

    Code:
    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 ?
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this and I'll explain what can be done (it is not specific to jRDC).
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    v1.00 is attached to the first post. It fixes an issue related to blobs.
     
  14. incendio

    incendio Well-Known Member Licensed User

    How to connect to multiple database and add support for SSL?
     
  15. Erel

    Erel Administrator Staff Member Licensed User

  16. incendio

    incendio Well-Known Member Licensed User

  17. Anser

    Anser Well-Known Member Licensed User

    Will this break my existing B4A code?

    In my code, I have many lines that check for Null For eg.
    Code:
    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 ?

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

    Regards
    Anser
     
  18. Erel

    Erel Administrator Staff Member Licensed User

    It will most probably work exactly as before. The change is not related to Null checking. It is related to the way Null parameters are bound to the query.
    It is only relevant to older jdbc drivers.
     
    Anser likes this.
  19. incendio

    incendio Well-Known Member Licensed 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.
     
    Anser likes this.
  20. Erel

    Erel Administrator Staff Member Licensed User

    If someone has access to the server files then nothing on the server is secure.

    I agree that it is better to move to jRDC.
     
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice