I have been writing login page with netbeans15. When I put the right value for both card number and password field it works intended work.
But when I put the wrong value for card number and password after this statement Rs= St.executeQuery(); the code is terminating, not even execute it's next statement System.out.println("Resultset"+ Rs);.
Rs not even contain null value for wrong card number and password.
My question is how to execute else statement for wrong card number and password? The code not entering into else block for wrong textfield!!
Connection Con = null;
PreparedStatement pst = null;
ResultSet Rs=null;
Statement St;
private void LoginTbMouseClicked(java.awt.event.MouseEvent evt) {
if(UnameTb.getText().isEmpty() || PasswordTb.getText().isEmpty()){
JOptionPane.showMessageDialog(this, "Enter Card and PIN Number");
}else{
String Query1 = "select * from AccountTbl where `Card Number`=? and `PIN`=?";
try{
Con = DriverManager.getConnection("jdbc:mysql://localhost:3306/CREDITDEBITDb","Amaity","Alok@2022");
PreparedStatement St = Con.prepareStatement(Query1);
Rs= St.executeQuery();
System.out.println("Resultset"+ Rs);
if(Rs.next()){
new MainMenu().setVisible(true);
this.dispose();
}else{
JOptionPane.showMessageDialog(this, "Wrong Card Numner or PIN");
}
}catch(HeadlessException | SQLException e){
}
} // TODO add your handling code here:
}