How to compare user input in a jTextfield with data in the database? (im using java & php)

Shammikit

Honorable
Nov 30, 2013
35
0
10,580
This is an assignment and so far this is what i have done:
on this button click i want to compare user input on the textfield with the data in my database.this is my code but nothing is happening when i run it and i cant find any mistakes in this. i have been trying to figure it out for hours but couldnt find any solution. can u please help me figure out whats wrong with it?


C++:
private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {                                          
      
        try{
        String s1 = s1_TextField.getText();
     
        String sql ="select s_no from people where s_no='" + s1 + "'";
        rs= st.executeQuery(sql);
             
        int c=0;
        while (rs.next())
         {
         c=c+1;
         }
        if(c==1)
        {
        JOptionPane.showMessageDialog(null,"user found");
        }
        else
        {
        JOptionPane.showMessageDialog(null,"Incorrect number");
        }
        }
        catch(Exception ex)
        {
        
        }
}
 

Shammikit

Honorable
Nov 30, 2013
35
0
10,580


i think i did it

C++:
     try{
     Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test_db", "root", "root");
     st=con.createStatement();
     }
    
    catch(Exception e)
    {
    
    }