Android 连接到远程服务器上的数据库时出错

我正在尝试将我的 android 应用程序连接到远程服务器上的数据库。我创建了一个登录表单,但它显示以下错误。



02/11 21:14:24: Launching app

No apk changes detected since last installation, skipping installation of C:\Users\manav\AndroidStudioProjects\MySQLConnect\app\build\outputs\apk\debug\app-debug.apk

$ adb shell am force-stop com.example.mysqlconnect

$ adb shell am start -n "com.example.mysqlconnect/com.example.mysqlconnect.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER

Connected to process 31621 on device xiaomi-redmi_note_3-dbdeee7e

Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.

W/System: ClassLoader referenced unknown path: /data/app/com.example.mysqlconnect-1/lib/arm64

D/AccessibilityManager: current package=com.example.mysqlconnect, accessibility manager mIsFinalEnabled=false, mOptimizeEnabled=false, mIsUiAutomationEnabled=false, mIsInterestedPackage=false

D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true

I/Adreno: QUALCOMM build                   : a7823f5, I59a6815413

    Build Date                       : 09/23/16

    OpenGL ES Shader Compiler Version: XE031.07.00.00

    Local Branch                     : mybranch22028469

    Remote Branch                    : quic/LA.BR.1.3.3_rb2.26

    Remote Branch                    : NONE

    Reconstruct Branch               : NOTHING

I/OpenGLRenderer: Initialized EGL, version 1.4

E/HAL: hw_get_module_by_class: module name gralloc

    hw_get_module_by_class: module name gralloc

I/Timeline: Timeline: Activity_launch_request time:71856102

D/OpenGLRenderer: endAllStagingAnimators on 0x559d757b20 (RippleDrawable) with handle 0x559d759ed0

I/DpmTcmClient: RegisterTcmMonitor from: com.android.okhttp.TcmIdleTimerMonitor

D/OpenGLRenderer: endAllStagingAnimators on 0x559d874d50 (RippleDrawable) with handle 0x559d89f8a0


以下是我的 Java 文件。


元芳怎么了
浏览 179回答 2
2回答

杨__羊羊

https://snipy.unaux.com/此网站 ssl 证书不受系统信任。您可以根据 okhttp doc 信任您的证书。或者您可以暂时将 https 替换为 http 来解决此问题。字符串 reg_url = " http://snipy.unaux.com/MySQLDemo/register.php ";字符串 login_url = " http://snipy.unaux.com/MySQLDemo/login.php ";

翻翻过去那场雪

检查 url 是 http 还是 https,然后将连接从 http 更改为 https:URL url = new URL(reg_url);HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();if (reg_url.startsWith("https://") {    SSLSocketFactory socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();    ((HttpsURLConnection) httpURLConnection).setSSLSocketFactory(socketFactory);}httpURLConnection.setRequestMethod("POST");httpURLConnection.setDoOutput(true);对登录执行相同的操作。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java