Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String sql = "select * from user where Username =? and password=?";
- try {
- pst = con.prepareStatement(sql);
- pst.setString(1, username.getText());
- pst.setString(2, password.getText());
- rs = pst.executeQuery();
- int count = 0;
- while (rs.next()) {
- count = count + 1;
- }
- if (count == 1) {
- JOptionPane.showMessageDialog(null, "Access Granted");
- if ("manager@manage.com".equals(t.getText())) {
- rs.close();
- pst.close();
- close();
- Admin_menu am = new Admin_menu();
- am.setVisible(true);
- } else {
- rs.close();
- pst.close();
- close();
- User_details M = new User_details();
- M.setVisible(true);
- }
- } else {
- JOptionPane.showMessageDialog(null, "Incorrect Username or Password");
- }
- } catch (Exception ex) {
- JOptionPane.showMessageDialog(null, ex);
- } finally {
- try {
- rs.close();
- pst.close();
- } catch (Exception ex) {
- }
- }
- //At login
- String a[]=new String[2];
- a[0]=username.getText();
- a[1]=new String(pass.getPassword());
- if(validate(a)){
- homescreen.steVisible(true);
- }
- //when user wishes to go to his homescreen
- if(validate(a)){
- homescreen.setVisible(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement