title: How to populate list view in android with connection to sql server
body: <p>Hi guys i have tried some codes but none work i was hoping if someone could help me. Bellow i will put my code</p>
  
  <p>AndroidManisfest:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.andre.marques.moldartsqlserver"&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:theme="@style/AppTheme"&gt;
      &lt;activity android:name=".InicioActivity"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity android:name=".OrdemFabricoActivity"&gt;&lt;/activity&gt;
  &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>activity_ordemfabrico.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  &lt;ListView
      android:id="@+id/EnterPays_atomPaysList"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      tools:listitem="@layout/ofselect"
      android:layout_below="@+id/layout_inf" &gt;
  &lt;/ListView&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>ofselect.xml:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="?android:listPreferredItemHeightSmall"
  android:orientation="horizontal"
  android:showDividers="middle"
  android:divider="?android:dividerVertical"
  android:dividerPadding="8dp"
  android:gravity="center"&gt;
  
  
  &lt;TextView android:id="@+id/Codart"
      style="?android:textAppearanceMedium"
      android:layout_width="0dp"
      android:layout_weight="1"
      android:layout_height="wrap_content"
      android:paddingLeft="?android:listPreferredItemPaddingLeft" /&gt;
  
  &lt;TextView android:id="@+id/quantidade"
      style="?android:textAppearanceMedium"
      android:layout_width="0dp"
      android:layout_weight="1"
      android:layout_height="wrap_content" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>ConnectionClass:</p>
  
  <pre><code>public class ConnectionClass {
  String ip;
  String classs;
  String db;
  String un;
  String password;
  public ConnectionClass() {
      classs = "net.sourceforge.jtds.jdbc.Driver";
      db = "DatabaseName";
      un = "user";
      password = "XXXXXXXX";
      ip = "192.xxx.x.xxx";
  }
  public ConnectionClass(String Ip, String Classs, String Db, String Un, String Password) {
      ip = Ip;
      classs = Classs;
      db = Db;
      un = Un;
      password = Password;
  }
  public String getip() {
      return ip;
  }
  public String getclasss() {
      return classs;
  }
  public String getdb() {
      return db;
  }
  public String getun() {
      return un;
  }
  public String getpassword() {
      return password;
  }
  public void setip(String Ip) {
      ip = Ip;
  }
  public void setdb(String Db) {
      db = Db;
  }
  public void setclasss(String Classs) {
      classs = Classs;
  }
  public void setun(String Un) {
      un = Un;
  }
  public void setpassword(String Password) {
      password = Password;
  }
  }
  </code></pre>
  
  <p>OrdemFabricoActivity:</p>
  
  <pre><code>public class OrdemFabricoActivity extends Activity {
  ConnectionClass connectionclass;
  ListView lst;
  SimpleAdapter ADAhere;
  String usernameS;
  String datets;
  String call, db, un, passwords;
  Connection connect;
  ResultSet rs;
  @SuppressLint("NewApi")
  private Connection CONN(String _user, String _pass, String _DB, String _server) {
      StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
      StrictMode.setThreadPolicy(policy);
      Connection conn = null;
      String ConnURL = null;
      try {
          Class.forName("net.sourceforge.jtds.jdbc.Driver");
          ConnURL = "jdbc:jtds:sqlserver://" + _server + ";" + "databaseName=" + _DB + ";user=" + _user + ";password=" + _pass + ";";
          conn = DriverManager.getConnection(ConnURL);
      } catch (SQLException se) {
          Log.e("ERRO", se.getMessage());
      } catch (ClassNotFoundException e) {
          Log.e("ERRO", e.getMessage());
      } catch (Exception e) {
          Log.e("ERRO", e.getMessage());
      }
      return conn;
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_ordemfabrico);
      lst = (ListView) findViewById(R.id.EnterPays_atomPaysList);
      /************* CONNECTION DATABASE VARIABLES ***************/
      connectionclass = new ConnectionClass();
      call = connectionclass.getip();
      un = connectionclass.getun();
      passwords = connectionclass.getpassword();
      db = connectionclass.getdb();
      connect = CONN(un, passwords, db, call);
  
      String querycmd = "select NUMOF, COD_ART, DESC_ART, OBSERVACOES, QUANT from tabof where tabof.ID_TO &lt;&gt; 5";
      try {
          Statement statement = connect.createStatement();
          rs = statement.executeQuery(querycmd);
          List&lt;Map&lt;String, String&gt;&gt; data = null;
          data = new ArrayList&lt;Map&lt;String, String&gt;&gt;();
          while (rs.next()) {
              Map&lt;String, String&gt; datanum = new HashMap&lt;String, String&gt;();
              datanum.put("A", rs.getString("COD_ART"));
              //datanum.put("B", rs.getString("QUANT"));
              data.add(datanum);
          }
          String[] fromwhere = { "A" };
          int[] viewswhere = { R.id.Codart };
          ADAhere = new SimpleAdapter(OrdemFabricoActivity.this, data, R.layout.ofselect, fromwhere, viewswhere);
          lst.setAdapter(ADAhere);
      } catch (SQLException e) {
          Toast.makeText(OrdemFabricoActivity.this, e.getMessage().toString(), Toast.LENGTH_LONG).show();
      }
  }
  }
  </code></pre>
  
  <p>This is my code the result that i get with this code it is when i go to this activity my phone screen is black and nothing happen. I wanted to put in the labels Codart and  quant the value of some camps of the database if someone know how to do this please help me.</p>