Oracle
 sql >> Teknologi Basis Data >  >> RDS >> Oracle

Bagaimana cara menghubungkan Android dengan database Oracle?

Gunakan Apache Server untuk menghubungkan android ke pc

Di php.ini buka oci8.dll

di htdocs buat file php. Kode php Anda adalah

<?PHP

 $con=
"(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = Your_ip)(PORT = 1521))
(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = Your_db_name)
)
)";
$conn = ocilogon( "User_name", "Password",$con,"WE8ISO8859P15");

$query = "select * from table_name";
        $parseresults = ociparse($conn, $query);

        ociexecute($parseresults);

    while($row=oci_fetch_assoc($parseresults))

 $output[]=$row;

 print json_encode($output);

oci_free_statement($parseresults);
oci_close($conn);

?>

Di android:

public class UploadActivity extends AsyncTask<Void, Void, String> {
Context context;

String result;

public UploadActivity(Context context) {
    this.context = context;
}

@SuppressWarnings("static-access")
@Override
protected void onPreExecute() {
    super.onPreExecute();


}

@Override
protected String doInBackground(Void... params) {
    // TODO Auto-generated method stub


    final List<Pair<String, String>> postParameters = new ArrayList<>();




        for (int i = 0; i < activity[0].length; i++) {

            //postParameters.add(new Pair<>("var1", activity[i][0]);

            result = null;


            try {

                String response = CustomHttpClient.execute(
                        URL + "Your_php.php", postParameters);
                result = response.toString();
                result = result.replaceAll("(\r\n|\n)", "");

            } catch (Exception e) {

                Log.e("log_tag_ms", "Error in http connection!!" + e.toString());

            }

        }


    return null;
}

protected void onPostExecute(String result) {
    super.onPostExecute(result);


    }  }



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Tampilan Oracle tidak dapat diperbarui, saran tentang Alih-alih pemicu

  2. Bagaimana cara menginstal Oracle instantclient dan pdo_oci di mesin ubuntu?

  3. Mengonversi OracleDecimal ke .NET desimal secara efisien dengan pemotongan

  4. Semantik CHAR dan ORA-01461

  5. Apakah 'Pilih' selalu diurutkan berdasarkan kunci utama?