title: connect android to MSSQL db using jtds.jdbc driver to specific port
body: <p>step by step instructions of how to connect android app to MSSQL database on Windows machine.</p>
  
  <p>struggling to find a right solution for connecting to MSSQL database from android using 
  jtds.jdbc driver, what makes it worst is that it is not clear for me whether the problem is with database or with jtds.jdbc driver.</p>
  
  <pre><code>public class DBTestActivity extends Activity {         
  
    private static final String url = "jdbc:jtds:sqlserver://10.0.2.2:1433;instance=testdb;DatabaseName=androidtest";
    private static final String user = "test\'testuser";
    private static final String pass = "testlog";
  
    TextView tv;
  
   @Override
   protected void onCreate(Bundle savedInstanceState) {
  
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dbconnect);
  
    final Button button = (Button) findViewById(R.id.connect);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
              Log.d("test3", "text4");
            // Perform action on click
            Connect();
            tv = (TextView) findViewById(R.id.db_text);
        }
    });
  
   }
  
    private class Connect extends AsyncTask&lt;String, Void, String&gt; {
      @Override
      protected String doInBackground(String... urls) {
        String response = "";
  
        try {
  
            Log.d("test5", "text5");
            Class.forName("net.sourceforge.jtds.jdbc.Driver");
            Log.d("test77", "text77");
  
            Connection con = DriverManager.getConnection(url, user, pass);
  
            Log.d("test12", "text12");
            String result = "Database connection success\n";
            Statement st = con.createStatement();
            ResultSet rs = st.executeQuery("select * from dbo.Test_Manufacturer");
            ResultSetMetaData rsmd = rs.getMetaData();*/
  
            while(rs.next()) {
              result += rsmd.getColumnName(1) + ": " + rs.getInt(1) + "\n";
              result += rsmd.getColumnName(2) + ": " + rs.getString(2) + "\n";
              result += rsmd.getColumnName(3) + ": " + rs.getString(3) + "\n";
            }
            tv.setText(result);
        }
        catch(Exception e) {
            e.printStackTrace();
           // tv.setText(e.toString());
        }
      Log.d("test20", "text212");
  
      return response;   
  
      }
  
     @Override
      protected void onPostExecute(String result) {
          Log.d("test2", "text2");
          tv.setText(result);
      }
    }
  
    public void Connect() {
  
        Log.d("test", "text1");
      Connect task = new Connect();
        task.execute();
  
      }
  
        }
  </code></pre>
  
  <p>Got different sort of errors:</p>
  
  <ul>
  <li>SQLException: server 10.0.2.2 has no instance named ......</li>
  <li>ECONNREFUSED</li>
  <li>COULD NOT FIND METHOD ORG.IETF.JGSS.GSSCONTEXT.INITSECCONTEXT</li>
  </ul>