i have written the following code
PrepareStatement stmt=con.prepareStatement("select * from studentdetails where sname=?");
String snm=jTextField10.getText();
ps.setString(1,snm);
ResultSet rs=stmt.executeQuery();
the problem i’m facing is that the result set is empty, i have checked with the database and the values i gave in the gui for search is valid. please tell me what migt be the problem.
Try the above code. Everything in your code is fine, only problem is with the ‘PreparedStatement instance’, and the ‘PrepareStatement’. It is ‘PreparedStatement’, you have missed the ‘d’ there. You have declared an instance of PreparedStatement called ‘stmt’ but you have set the value using another called ‘ps’.
Small Note:
I don’t like the name you have given to the JTextField. in OOP, it is recommended to give a meaningful names to instances, Objects, Methods, Variables etc