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

Daniel44

Active 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
 

OliverA

Expert
Licensed User
Longtime User
JRDC2 really seems to be made only to run on B4A
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)
B4X:
Public mysql As JdbcSQL
to
B4X:
Public mysql As SQL
2) In the Starter service change (line 53)
B4X:
Wait For (sf) mysql_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
to
B4X:
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
B4X:
Log($"Id: ${Crsr.GetInt("id")}, Name: ${Crsr.GetString("name")}"$)
to display the data retrieved with your query
 
Upvote 0

Daniel44

Active Member
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)
B4X:
Public mysql As JdbcSQL
to
B4X:
Public mysql As SQL
2) In the Starter service change (line 53)
B4X:
Wait For (sf) mysql_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
to
B4X:
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
B4X:
Log($"Id: ${Crsr.GetInt("id")}, Name: ${Crsr.GetString("name")}"$)
to display the data retrieved with your query

Hi! Thank you for answering . I'll try !
 
Upvote 0

josejad

Expert
Licensed User
Longtime 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
 
Upvote 0

Daniel44

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