Advertisement
lindyleekron

login button action

Dec 31st, 2012
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.71 KB | None | 0 0
  1.         try {
  2.             String sql="Select * from Users1";
  3.             String host ="jdbc:derby://localhost:1527/Nash";
  4.             String uName = "CON";
  5.             String uPass = "smokes";
  6.             Connection con = DriverManager.getConnection(host, uName, uPass);
  7.             Statement stmt=con.createStatement();
  8.             ResultSet rs = stmt.executeQuery(sql);
  9.             String user= userName.getText();
  10.             String pwd= password.getText();
  11.             while(rs.next()) {
  12.             String uname=rs.getString("User_name");
  13.             String pass=rs.getString("Password");
  14.             String admin1=rs.getString("admin");
  15.            
  16.     if ((user.equals(uname)) && (pwd.equals(pass)))
  17.         {
  18.             if ((admin1.equals("y")))
  19.             {  
  20.                 mainPanel.setVisible(true);
  21.                 blankContent.setVisible(true);
  22.                 adminButton.setEnabled(true);
  23.                 receiptContent.setVisible(false);
  24.                memberContent.setVisible(false);
  25.                securityPanel.setVisible(false);
  26.             }
  27.             else
  28.             {
  29.                mainPanel.setVisible(true);
  30.                blankContent.setVisible(true);
  31.                adminButton.setEnabled(false);
  32.                receiptContent.setVisible(false);
  33.                memberContent.setVisible(false);
  34.                securityPanel.setVisible(false);
  35.             }
  36. }
  37. else
  38. {
  39.    JOptionPane.showMessageDialog(null,  "User name and password do"
  40.    + " not match!","ALERT!", JOptionPane.ERROR_MESSAGE);
  41.                  
  42.                 }  
  43.     }   } catch (SQLException ex) {
  44.             Logger.getLogger(program.class.getName()).log(Level.SEVERE, null, ex);
  45.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement