亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Android 連接到遠程服務器上的數據庫時出錯

Android 連接到遠程服務器上的數據庫時出錯

元芳怎么了 2022-06-15 10:53:05
我正在嘗試將我的 android 應用程序連接到遠程服務器上的數據庫。我創建了一個登錄表單,但它顯示以下錯誤。02/11 21:14:24: Launching appNo 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.LAUNCHERConnected to process 31621 on device xiaomi-redmi_note_3-dbdeee7eCapturing 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/arm64D/AccessibilityManager: current package=com.example.mysqlconnect, accessibility manager mIsFinalEnabled=false, mOptimizeEnabled=false, mIsUiAutomationEnabled=false, mIsInterestedPackage=falseD/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: trueI/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               : NOTHINGI/OpenGLRenderer: Initialized EGL, version 1.4E/HAL: hw_get_module_by_class: module name gralloc    hw_get_module_by_class: module name grallocI/Timeline: Timeline: Activity_launch_request time:71856102D/OpenGLRenderer: endAllStagingAnimators on 0x559d757b20 (RippleDrawable) with handle 0x559d759ed0I/DpmTcmClient: RegisterTcmMonitor from: com.android.okhttp.TcmIdleTimerMonitorD/OpenGLRenderer: endAllStagingAnimators on 0x559d874d50 (RippleDrawable) with handle 0x559d89f8a0以下是我的 Java 文件。
查看完整描述

2 回答

?
楊__羊羊

TA貢獻1943條經驗 獲得超7個贊

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 ";


查看完整回答
反對 回復 2022-06-15
?
翻翻過去那場雪

TA貢獻2065條經驗 獲得超14個贊

檢查 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);

對登錄執行相同的操作。


查看完整回答
反對 回復 2022-06-15
  • 2 回答
  • 0 關注
  • 177 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號