Advertisement
Guest User

Untitled

a guest
Feb 13th, 2017
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. String sql ="select Id,Username,Password,Division from Users where (username =? and password= ? and division=?)";
  2.  
  3. try{
  4. int count = 0;
  5. pst = conn.prepareStatement(sql);
  6.  
  7. pst.setString(1, txt_username.getText());
  8. pst.setString(2, txt_password.getText());
  9. pst.setString(3, txt_combo.getSelectedItem().toString());
  10.  
  11. rs = pst.executeQuery();
  12. while (rs.next()){
  13. int Username =rs.getInt(1);
  14. Emp.empnum = Username;
  15. String username = rs.getString("username");
  16. Emp.empname = username;
  17. count = count+1;
  18. }
  19.  
  20. String access = (txt_combo.getSelectedItem().toString());
  21.  
  22. if(access =="Administrator,Admin,User"){
  23. if(count == 1){
  24. JOptionPane.showMessageDialog(null, "Success");
  25. MainMenu j = new MainMenu();
  26. j.setVisible(true);
  27. this.dispose();
  28. }else {
  29. JOptionPane.showMessageDialog(null, "The Username or Password you entered was incorrect!");
  30. }
  31. }
  32.  
  33. }catch (Exception e){
  34.  
  35. JOptionPane.showMessageDialog(null, e);
  36.  
  37. }
  38. finally {
  39.  
  40. try{
  41. rs.close();
  42. pst.close();
  43.  
  44. }catch (Exception e){
  45. }
  46. }
  47. }`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement