Android Question jRDC2: How to make it work on B4A?

Discussion in 'Android Questions' started by Daniel44, Sep 27, 2019.

  1. Daniel44

    Daniel44 Member Licensed User

    I have seen tutorials here and on youtube but the only thing I see is that you have to run a server which only runs with B4J and then make it work on B4A¿? I would like to use it but the truth is that JRDC2 really seems to be made only to run on B4A. Unfortunately I haven't been able to find a single example of jRDC2 in B4A that is concise and clear and that works. I've tried to run the few confusing examples here about jRDC2 and there's no way it works in B4A without that blissful "Jetty" Server. Can someone create a "BASIC" example of a connection to a MYSQL DB in B4A and show a table correctly? Thank you
     
  2. OliverA

    OliverA Expert Licensed User

    Actually, jRDC2 is designed to be compiled with B4J, not B4A. It can be accessed via B4A/B4i and B4J (B4R via a MQQT gateway). If you want to access your DB directly from your Android device, then you need to check out jSQL. jSQL previously (before becoming an internal lib) was called JdbcSQL. The post announcing JdbcSQL (https://www.b4x.com/android/forum/threads/jdbcsql-directly-connect-to-remote-databases.84016/) has a demo program included that needs a couple of modifications to be able to work.
    0) Include/enable the jSQL library in the library tab
    1) In the Starter service change (line 6)
    Code:
    Public mysql As JdbcSQL
    to
    Code:
    Public mysql As SQL
    2) In the Starter service change (line 53)
    Code:
    Wait For (sf) mysql_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
    to
    Code:
    Wait For (sf) mysql_QueryComplete (Success As Boolean, Crsr As ResultSet)
    3) Change the Starter service global variables jdbcUrl, Username and Password to work with your installed MySQL DB.
    4) If you use the SQL statement of that program, make sure you have a table set up in you DB that can handle the query or change the query and the
    Code:
    Log($"Id: ${Crsr.GetInt("id")}, Name: ${Crsr.GetString("name")}"$)
    to display the data retrieved with your query
     
  3. Daniel44

    Daniel44 Member Licensed User

    Hi! Thank you for answering . I'll try !
     
  4. José J. Aguilar

    José J. Aguilar Well-Known Member Licensed User

    Hi Daniel44, just to clarify:

    - jRDC2 is a B4J program, you compile it in B4J as OliverA told you, and you need a VPS where you can host the .jar. It will act as a server.
    - The jRDC2 server, will connect with your database
    - Then, you can access the jRDC2 server from another B4J client program, or from a B4A or B4I app.

    So, jRDC2 is a server between your app and and your database
     
  5. Daniel44

    Daniel44 Member Licensed User

    I thought that.... I must have B4J to compile. Jeje fine... anyway thank you so much for answering.
     
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