title: Android Connection with Oracle Database
body: <p>by clicking a button, i want to execute a select query to show some results,i used the Internet permission and the AsyncTask and the address ip of my PC to perform this call but it didn t work for me,Also the Log doesn't show me Anything to figure out the issue,this is the code:</p>
  
  <p>in Manifest file:</p>
  
  <pre><code> &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  </code></pre>
  
  <p>Android programm:</p>
  
  <pre><code>package com.ammach.oraclecon;  
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.util.Log;
  import android.view.View;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.sql.Statement;
  
  public class MainActivity extends AppCompatActivity {
  
  
      class Task extends AsyncTask&lt;Void,Void,String&gt;{
  
          @Override
          protected String doInBackground(Void... params) {
  
              String param="mal9a walou";
              String driver="oracle.jdbc.driver.OracleDriver";
              String bd="ORCL";
              String user="SYSTEM";
              String passwd="SYSTEM";
              String port="1521";
              String ip="192.168.1.7";
              String url="jdbc:oracle:thin:@"+ip+":"+port+":"+bd;
  
              Connection con=null;
                  try {
                      Class.forName(driver);
                      con = DriverManager.getConnection(url, user, passwd);
                      Log.e("coooon", "coooon");
                      Statement st=con.createStatement();
                      Log.e("Statement", "Statement");
                      ResultSet resultSet = st.executeQuery("select * from auteur");
                      Log.e("ResultSet", "ResultSet");
  
                      Log.e("con", "You made it, take control your database now!");
                      if(resultSet.next()){
                          param=resultSet.getString("nom");
                          Log.e("dkhal", "rah dkhal");
                      }else{
                          Log.e("walou", "walou");
                      }
  
                  } catch (SQLException | ClassNotFoundException e) {
                      e.printStackTrace();
                  }
  
  
              return param;
          }
  
          @Override
          protected void onPostExecute(String param) {
              super.onPostExecute(param);
              textView.setText(param);
              Toast.makeText(MainActivity.this, "finished", Toast.LENGTH_SHORT).show();
          }
      }
  
      TextView textView;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          textView= (TextView) findViewById(R.id.txt);
      }
  
      public void fetchOracle(View view) {
  
          new Task().execute();
          Toast.makeText(MainActivity.this, "starting", Toast.LENGTH_SHORT).show();
      }
  }
  </code></pre>
  
  <p>i Also run the same procedure in a simple java project(void main) in Netbeans, and it works perfectly,i tried so many times the Android application but i failed ,could someone help me to solve this issue.</p>
  
  <p>this is the java programm:</p>
  
  <pre><code>        String param = "nothing";
          String driver = "oracle.jdbc.driver.OracleDriver";
          String bd = "ORCL";
          String user = "SYSTEM";
          String passwd = "SYSTEM";
          String port = "1521";
          String ip = "localhost";
          String url = "jdbc:oracle:thin:@" + ip + ":" + port + ":" + bd;
  
          Connection con = null;
          try {
              Class.forName(driver);
              con = DriverManager.getConnection(url, user, passwd);
              Statement st = con.createStatement();
              ResultSet resultSet = st.executeQuery("select * from auteur");
              if (resultSet.next()) {
                  param = resultSet.getString("nom");
  
              } else {
                  System.out.println("no result");
              }
              System.out.println("nom: "+param);
          } catch (SQLException | ClassNotFoundException e) {
              e.printStackTrace();
          } 
  </code></pre>