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
0
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
0


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)
    {
    
    }
 
Thread starter Similar threads Forum Replies Date
O Apps General Discussion 2
S Apps General Discussion 5
S Apps General Discussion 8
N Apps General Discussion 1
TVTED Apps General Discussion 8
TVTED Apps General Discussion 2
Z Apps General Discussion 4
X Apps General Discussion 13
T Apps General Discussion 2
henrytcasey Apps General Discussion 7
N Apps General Discussion 11
R Apps General Discussion 1
Q Apps General Discussion 9
K Apps General Discussion 1
T Apps General Discussion 3
D Apps General Discussion 3
F Apps General Discussion 1
commissarmo Apps General Discussion 3
U Apps General Discussion 1
R Apps General Discussion 3

ASK THE COMMUNITY