B4J Question Remote Database Connector continue...

Reinierus

Member
Licensed User
Longtime User
Hello.
Continuing with my learning from this post:

I followed the tutorial like the video and I get the correct connection on the web browser:
1591050931819.png

And in the Android device:


WhatsApp Image 2020-06-01 at 4.37.10 PM.jpeg


But when I execute the command, I have this error:

PackageAdded: package:b4a.example
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Busqueda...
dbrequestmanager_vv0 (java line: 395)
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/client/methods/HttpPost;
at anywheresoftware.b4a.http.HttpClientWrapper$HttpUriRequestWrapper.InitializePost2(HttpClientWrapper.java:395)
at anywheresoftware.b4a.samples.httputils2.httpjob._postbytes(httpjob.java:185)
at b4a.example.dbrequestmanager._vv0(dbrequestmanager.java:395)
at b4a.example.dbrequestmanager._vv2(dbrequestmanager.java:181)
at b4a.example.main$ResumableSub_GetRecord.resume(main.java:476)
at b4a.example.main._vvv7(main.java:448)
at b4a.example.main._button1_click(main.java:406)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6663)
at android.view.View.performClickInternal(View.java:6635)
at android.view.View.access$3100(View.java:794)
at android.view.View$PerformClick.run(View.java:26199)
at android.os.Handler.handleCallback(Handler.java:907)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.client.methods.HttpPost" on path: DexPathList[[zip file "/data/app/b4a.example-PXDxGB5rCDqNkszgJMX6rQ==/base.apk"],nativeLibraryDirectories=[/data/app/b4a.example-PXDxGB5rCDqNkszgJMX6rQ==/lib/arm64, /system/lib64, /product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 23 more
dbrequestmanager_vv0 (java line: 395)
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/client/methods/HttpPost;
at anywheresoftware.b4a.http.HttpClientWrapper$HttpUriRequestWrapper.InitializePost2(HttpClientWrapper.java:395)
at anywheresoftware.b4a.samples.httputils2.httpjob._postbytes(httpjob.java:185)
at b4a.example.dbrequestmanager._vv0(dbrequestmanager.java:395)
at b4a.example.dbrequestmanager._vv2(dbrequestmanager.java:181)
at b4a.example.main$ResumableSub_GetRecord.resume(main.java:476)
at b4a.example.main._vvv7(main.java:448)
at b4a.example.main._button1_click(main.java:406)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6663)
at android.view.View.performClickInternal(View.java:6635)
at android.view.View.access$3100(View.java:794)
at android.view.View$PerformClick.run(View.java:26199)
at android.os.Handler.handleCallback(Handler.java:907)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.client.methods.HttpPost" on path: DexPathList[[zip file "/data/app/b4a.example-PXDxGB5rCDqNkszgJMX6rQ==/base.apk"],nativeLibraryDirectories=[/data/app/b4a.example-PXDxGB5rCDqNkszgJMX6rQ==/lib/arm64, /system/lib64, /product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 23 more

The only difference is I am trying to connect to a remote database:
1591051967397.png


Code:
Sub GetRecord
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("select_usuarios", Null)
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    If j.Success Then
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        'work with result
        req.PrintTable(res)
    Else
        Log("ERROR: " & j.ErrorMessage)
    End If
    j.Release
End Sub

I am doing something wrong again or it is the remote server?

Thanks
 

TILogistic

Expert
Licensed User
Longtime User
if so, it must give access to port 3306 of the server that contains the database.

and give remote access permission to the user connecting to the database mysql
 
Upvote 0

Reinierus

Member
Licensed User
Longtime User
Are you connecting from another PC to your server?
I am doing the same as the video tutorial

Español.
No entiendo muy bien lo que hace Erel en el video, porque crea un servidor para conectarse a una base de datos remota, pero los dispositivos se conectan al servidor que el crea (¿?) en una PC local.
 
Upvote 0

Reinierus

Member
Licensed User
Longtime User
Yes, I put the % wildcard to grant access to any client. It is for trying.

Español.
Creo que es un tema de permisos o de algun driver, porque en el tutorial el hace todo desde una PC local (así cualquiera), pero a la hora de hacerlo conectándolo a una base de datos remota me da el error.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
This has nothing to do with your jRDC2 server. What library do you have checked in B4A for your http requests? Looks like you are using and ancient library (the mentioning of apache.org in the error message hints at using the wrong library)
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
This has nothing to do with your jRDC2 server. What library do you have checked in B4A for your http requests? Looks like you are using and ancient library (the mentioning of apache.org in the error message hints at using the wrong library)

if you check the versions of the HTTP and SQL libraries of your Android app.

sorry i didn't see the error.

My mind was solving some problems of a client in the banking area.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Based on the error:
Probably

- 28 - The old http SDK is not available by default. This will cause problems with native libraries such as Google Maps who rely on the old SDK. To enable it: https://www.b4x.com/android/forum/t...ar-error-in-android-9-pie.103247/#post-649875 - 28 - The old http SDK is not available by default. This will cause problems with native libraries such as Google Maps who rely on the old SDK. To enable it: https://www.b4x.com/android/forum/t...ar-error-in-android-9-pie.103247/#post-649875
 
Upvote 0

Reinierus

Member
Licensed User
Longtime User
Hello. You were right, the libraries was too old and with the new ones it is working.
Now I need to make that the database is accessible over internet (not only from the Wifi)

Thanks a lot
 
Upvote 0

Reinierus

Member
Licensed User
Longtime User
Now I getting this error in B4A:
ResponseError. Reason: javax.net.ssl.SSLHandshakeException: Handshake failed, Response:
ERROR: javax.net.ssl.SSLHandshakeException: Handshake failed

I am using this libraries:
1591413219392.png

I think there are the last versions.

Thanks
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Did you set up SSL on your jRDC2 server? If not, don’t use https in the URL
 
Upvote 0

Reinierus

Member
Licensed User
Longtime User
If I don't use https, I get this error:
ResponseError. Reason: java.net.UnknownServiceException: CLEARTEXT communication to 192.168.10.139 not permitted by network security policy, Response:
ERROR: java.net.UnknownServiceException: CLEARTEXT communication to 192.168.10.139 not permitted by network security policy

I have the Firewall off in my computer

Thanks
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0
Top