Hi every one!!
I need help to match user data from database inorder to log in to admin panel. Here is what I am trying. it works ok but it is giving dialog box containing text "Sorry! You have no access to Database"
here is the code. Please help
String user = jTextField1.getText();
String pwd = new String(jPasswordField1.getPassword());
while (rs.next()) {
String uname = rs.getString("User name");
//Username is the coloumn name in the database table
String password = rs.getString("Password");
if ((user.equals(uname)) && (pwd.equals(password))) {
admin_panel p = new admin_panel();
p.setVisible(true);
} else if ((!user.equals(uname)) && (!pwd.equals(password))) { // System.out.println("Sorry! You have no access to Database");
JOptionPane.showMessageDialog(null, "Sorry! You have no access to Database");
}
//new login().setVisible(true);
};
I need to use vriables in while loop, outside while loop. please guide how to do this