Android Question mysql connection

gpbimal

Member
Dear Developers

I want to connect a remote database (mysql) with b4a application. I'm basic in B4A because I'm a VB Developer.

I've read
jRDC2 - Connect to remote databases from B4A example sites, view in YouTube and follow the given instruction.

But I unable to connect my database.

I just want b4a code for:
1. Successful connection code for my various remote database.
2. Get data and bind in ListView one by one.

3. Run an Insert query.

That's all

I can pay $30-40 for this. Please help...
 

gpbimal

Member
First of all I'm sorry for my bad English.
I can not connect mysql database with b4a project, my database is hosted in , database name is gsddemoz_sp
Now, I need an example project with following requirements.
1. Connection with remote MySql database hosted in https://www.gsddemoz.com
a. database name = gsddemoz_sp
b. table name = userlist
2. I want to bind all users (username is column name) in ListView.
3. I want to add a new username in userlist table.

If I get the B4A example project mentioned as above, all the remaining works I can do. Because I've already work with sqlite data in several projects.

Thank you Erel.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I think we can develop in local first then only migrate to production.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

aeric

Expert
Licensed User
Longtime User
For anyone here to help you further, you need to provide more info like error log or post the code that you think cause the issue.

I recommend you follow the tutorial again and then ask which part you don't understand.

You may also use the search function to search the question which already been asked by someone else. You may find the questions already solved.
 
Upvote 0

Bladimir Silva Toro

Active Member
Licensed User
Hi @gpbimal

There are 3 ways to connect to a database from B4A:

1. jRDC: it is a middleware that runs in JAVA, for this you need your own web server or a VPS web service. Look here: https://www.webhostnepal.com/cloud-vps

2. WebService: You can create your own web service either in PHP, ASP, JSP, you must share the information with a JSON. You only need a Web Hosting. Look here: https://www.webhostnepal.com/hosting

3. Direct JdbcSQL connection: For this you only need a web server and that your database supports remote connections. You only need a Web Hosting. Look here: https://www.webhostnepal.com/hosting

Choose the way you want, all the information can be found in the forums.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Are you using default port 3306 for mysql ?
 
Upvote 0

José J. Aguilar

Expert
Licensed User
It seems you have test your jRDC2 connection from the same computer running the server.
1590130821132.png


Have you tried to access 192.168.10.10:17178/test from another computer, or from the the android browser? Maybe a firewall problem.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Do you change AppStart in B4J server app?
B4X:
srvr.AddHandler("/rdc", "RDCHandler", False)
 
Upvote 0

gpbimal

Member
Do you change AppStart in B4J server app?
B4X:
srvr.AddHandler("/rdc", "RDCHandler", False)

Dear Aeric, yes it was already configured in the source in which i downloaded.

Sub AppStart (Args() As String)
srvr.Initialize("")
rdcConnector1.Initialize
srvr.Port = rdcConnector1.serverPort
srvr.AddHandler("/test", "TestHandler", False)
srvr.AddHandler("/rdc", "RDCHandler", False)
srvr.Start
Log($"jRDC is running (version = $1.2{VERSION})"$)
StartMessageLoop
End Sub
 
Upvote 0

gpbimal

Member
Do you get any connection in the B4J Log?
If you don't see it, your B4A app is not reaching your jRDC2 server

Yes, It shows JRDC is running as shown in the picture below.

1590146211774.png



But I'm not sure that B4J is connected with database or not.
Will you please tell me how to check it?

Thank you.
 

Attachments

  • 1590144647832.png
    1590144647832.png
    27.7 KB · Views: 69
  • 1590146076669.png
    1590146076669.png
    42 KB · Views: 77
Last edited:
Upvote 0

OliverA

Expert
Licensed User
In post#10, you (@gpbimal ) show the log from the B4A app. You also show the log from the B4J server. Something is not correct right there. Your jRDC2 server log should have had a log entry for the exceptions also.
Just for fun, instead of
B4X:
Dim cmd As DBCommand = CreateCommand("select_users", Null)
Try
B4X:
Dim cmd As DBCommand = CreateCommand("select_users", Array())
Why? In my notes of my modified jRDC2 server I have that a Null pointer exception can occur when cmd.Parameters is set to Null

Note: Please start posting code and logs as text. Easier to copy paste than have to look at a picture and type out
 
Upvote 0
Top