title: Thread is not running in android
body: <p>I'm trying to connect my android application with mysql database using jdbc driver. I searched a lot and found that using thread or AsyncTask  we can connect to the mysql directly. But i found difficult in asynctask, So i'm using thread to do that. Here is my code : </p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.search_customer);
      TextView t = (TextView) findViewById(R.id.Search_Customer_textView1);
      Button b = (Button) findViewById(R.id.Search_Customer_button1);
      b.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
  
              Thread timer=new Thread(){
                  public void run(){
                      try {
                          Class.forName("com.mysql.jdbc.Driver");
                          con = DriverManager.getConnection("jdbc:mysql://192.168.1.102:3306/outsidelaundry", "root", "");
                          Statement stmt = con.createStatement();
                          String query = "select Name from nonmember";
                          ResultSet rs = stmt.executeQuery(query);        
                          while(rs.next())
                          {
                              val = val + rs.getString(1) + "\n";
                          }
                          Toast.makeText(getApplicationContext(), val, Toast.LENGTH_LONG).show();
                          con.close();
  
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
                  }
              };
              timer.start();
              Toast.makeText(getApplicationContext(), "pressed", Toast.LENGTH_LONG).show();
          }
      });
  
      }
  </code></pre>
  
  <p>When i run the program thread is not starting/running. I didn't get any exception. Please help me with this.</p>