title: How to connect sql server to android application?
body: <pre><code>public class MainActivity extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          Button btn=(Button)findViewById(R.id.button1);
  
          btn.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  connection();
              }
          });
  
      }
  
      public void connection(){
          try {
  
              Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
  
              Connection conn=DriverManager.getConnection("jdbc:jtds:sqlserver://Asus-PC/PJH.V1;","","");
              Log.w("Connection", "Error");
  
              Statement stat=conn.createStatement();          
              ResultSet result=stat.executeQuery("SELECT * FROM Javher1");
  
              TextView tv=(TextView)findViewById(R.id.textView1);
              tv.setText(result.getString(1));
              conn.close();
  
          } catch (Exception e) {
              // TODO: handle exception
              Log.e("Error",e.getMessage());
              Toast.makeText(getApplicationContext(), "Error"+e.getMessage(), Toast.LENGTH_LONG).show();
          }
  
      }
  }
  </code></pre>
  
  <p>I added a  jtds1.2.7-jar file to the library.</p>
  
  <p>The code runs I get the following error:</p>
  
  <blockquote>
    <p>Error:Unknown server host name 'Asus-PC'.</p>
  </blockquote>
  
  <p>If anyone knows anything please help me!</p>
  
  <p>Thanks in advance.</p>