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

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

gpbimal

Member
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

Thank you very much for your valuable suggestion. I'll follow the instructions.
 
Upvote 0

Bladimir Silva Toro

Active Member
Licensed User
Longtime User
Hi @gpbimal

1590242975291.png


Click on the green arrow there and save the ZIP.

Attached is ZIP to see the errors in your code

Please also attach your MySQL database script
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Was this ever resolved? This had nothing to do with database connectivity. @Erel is correct. You missed a step when you created your B4A application. Both DBCommand and DBRequest Types have to be declared in Proccess_Globals of your Main activity! Not in any other activty/class/service module. The interesting part is that the server showed the correct error message
(ClassNotFoundException) java.lang.ClassNotFoundException: b4j.example.test$_dbcommand
But the initial screenshot of you B4A app showed a null pointer exception. Don't know if this is because of B4A, because in B4J, the exception reported is the same
ResponseError. Reason: java.lang.ClassNotFoundException: b4j.example.test$_dbcommand, Response: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 500 java.lang.ClassNotFoundException: b4j.example.test$_dbcommand</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /rdc. Reason:
<pre> java.lang.ClassNotFoundException: b4j.example.test$_dbcommand</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 500 java.lang.ClassNotFoundException: b4j.example.test$_dbcommand</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /rdc. Reason:
<pre> java.lang.ClassNotFoundException: b4j.example.test$_dbcommand</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>
</body>
</html>
 
Upvote 0

gpbimal

Member
Thanks a lot all of you! connection is made successfully. I'm loving it....
@Erel yes I missed a step, thank you once again to correct me...
Local connection has made, now trying with web server. I hope I can do this.
And trying to binding data with spinner, listview or labels etc.

I want to try it with my best efforts, Thanks
 
Upvote 0

gpbimal

Member
Hi!
I've connected with local-host mysql database as well. I've changed the server IPAddress in config.properties file and run the B4J in release mode. A jRDC.jar file is created. I've no idea how to run that jRDC.jar file in server (to use it as middle ware) to connect online database with client application. Please help...
 
Upvote 0

Bladimir Silva Toro

Active Member
Licensed User
Longtime User
Hi @gpbimal

You can do it in 2 ways:

1. Request a public IP from your internet provider (ISP) so that your computer can be accessed online from anywhere in the world

2. Rent a Web server that can be managed are called VPS services.

Windows Link: https://www.vps-mart.com/Windows-VPS
Linux Link: https://www.vps-mart.com/Linux-VPS

Here I leave you the code of the BAT file that I execute when the computer starts up.

B4X:
@echo off

java -jar "D:\jRDC.jar"

pause
exit
 
Upvote 0
Top