我正在使用帶有 Sqlserver 的 Android Studio 創(chuàng)建一個簡單的 CRUD。當(dāng)我將數(shù)據(jù)添加到數(shù)據(jù)庫中時,出現(xiàn)錯誤 ConnectionRefusedError。我已將代碼附在到目前為止我嘗試過的代碼下方。我一直在嘗試連接數(shù)據(jù)庫 2 兩天,但它沒有讓我這樣做。我成功添加jar文件jtds-1.2.7.jar我得到了 SQL 服務(wù)器的 IP 地址及其端口XML<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity"> <TextView android:id="@+id/view" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="View" /> <EditText android:id="@+id/title" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" /> <EditText android:id="@+id/course" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputType="textMultiLine" /> <Button android:id="@+id/btn1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="OK" /> <Button android:id="@+id/v1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="View" /></LinearLayout>
1 回答

慕桂英546537
TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超10個贊
該ConnectionRefused
錯誤僅表示主機(jī)拒絕該端口上的連接。也許該端口在主機(jī)的防火墻上被阻止了?如果您有權(quán)訪問主機(jī),則可以簡單地取消阻止該端口。請報(bào)告您的發(fā)現(xiàn)。
添加回答
舉報(bào)
0/150
提交
取消