title: How to connect Android application to SQL Server through jbdc?
body: <p>I have tried to connect my Android app to SQL Server using jtds but it gives a login error.</p>
  
  <p>I have use jtds1.2.7-jar in my libs folder</p>
  
  <p>My code is:</p>
  
  <pre><code>public class MainAct extends Activity{
  EditText e;
  Button bt;
  ListView lv;
  Connection connect;
  SimpleAdapter sm;
  
  public void declere(){
      e=(EditText)findViewById(R.id.et1);
      bt=(Button)findViewById(R.id.bt1);
      lv=(ListView)findViewById(R.id.list);
  }
  
  public void initilize(){
      declere();
      e.setText("SELECT TOP 10 * FROM FORM1");
      connect=CONN("sa","cbo@morc","KULDEEP","122.160.255.218:1433");
  }
  @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 + ";passward=" + pass + ";";
       conn=DriverManager.getConnection(connUrl);
       }catch(SQLException se){
           Log.e("ERROR", se.getMessage());
       }catch(ClassNotFoundException cl){
           Log.e("ERROR", cl.getMessage());
       }catch(Exception e){
           Log.e("ERROR", e.getMessage());
       }
  
       return conn;
  
      }
  
     public void querySQL(String COMMANDSQL){
         ResultSet rs;
         try{
         Statement statement=connect.createStatement();
         rs=statement.executeQuery(COMMANDSQL);
         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("NAME"));
             datanum.put("b", rs.getString("CITY"));
             data.add(datanum);
         }
         String [] from={"a","b"};
         int [] to={R.id.tv1,R.id.tv2};
  
         sm=new SimpleAdapter(this, data, R.layout.second, from, to);
         lv.setAdapter(sm);
         }catch(Exception e){
            Log.e("ERROR", e.getMessage()); 
         }
  
     }
  public void onCreate(Bundle b){
      super.onCreate(b);
      setContentView(R.layout.main);
      initilize();
  
      bt.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              querySQL(e.getText().toString());
  
  
          }
      });
  }
  }
  </code></pre>