I am having problem with database, creating a login screen that has 1 choice box, 1 textfield for username, 1 jpasswordfield for password. Database name-admin(username text,password text)
It's showing an error. How can I fix this.
Here is my code:
if(choice.getSelectedIndex()==1)
{
try {
String sql ="SELECT password FROM admin WHERE username = ? AND password = ?";
pst = con.prepareStatement(sql);
pst.setString(1, UserName.getText());
/*Showing: "The method setString(int, String) in the type
PreparedStatement is not applicable for the arguments (int, char[])*/
pst.setString(2,passwordField.getPassword());
}
catch(Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}