title: Cannot retrieve data into Jtextfield from MySql Database
body: <pre><code> try
                      {
                          st=cn.createStatement();
                          String strUser="";
                          rs=st.executeQuery("SELECT * FROM chsl_db WHERE name='"+nametxt.getText()+"'");
                          while(rs.next())
                          {
                              strUser=rs.getString(1);
                          }
                          if(strUser.equals(nametxt.getText()))
                          {
                          st= cn.createStatement();
                          rs = st.executeQuery("SELECT * FROM chsl_db WHERE name ='" + nametxt.getText() + "'");
                          while (rs.next()) 
                          {
                              titletxt.setText(rs.getString(1));
                              nametxt.setText(rs.getString(2));
                              flatnum.setText(rs.getString(3));
                              areatxt.setText(rs.getString(4));
                              emailtxt.setText(rs.getString(5));
                              deletebutton.setEnabled(true);
                          }
  
                          st.close();
                          }
                              else
                              {
                                  JOptionPane.showMessageDialog(null,"No Data Found!","Security Warning",JOptionPane.WARNING_MESSAGE);
                                      }
  
                                      }
  
      catch(SQLException s)
      {
          System.out.println("No record found!\n\n\n");
          System.out.println("SQL Error" + s.toString() + " " + s.getErrorCode() + " " + s.getSQLState());
      }
  catch(Exception x)
      {
          System.out.println("Error" + x.toString()+" " + x.getMessage());
      }   
  
  }                        
  </code></pre>
  
  <p>Project on Netbeans Using MySql Workbench as Database. Insert Data into Database is Working but cannot retrieve the same. It throws error "No Data Found!". Checked the connection and its ok. Below are the codes that i used to establish connection. Please Help !!  </p>
  
  <pre><code>try
      {
          Class.forName("java.sql.Driver");
          cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/avinash?useSSL=false","root","password");
      }
              catch(ClassNotFoundException e)  
              {
          System.err.println("Failed to load driver");
          e.printStackTrace();
      }
      catch(SQLException e)
              {
          System.err.println("Unable to connect");
          e.printStackTrace();
      }
  </code></pre>