Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String sql ="select Id,Username,Password,Division from Users where (username =? and password= ? and division=?)";
- try{
- int count = 0;
- pst = conn.prepareStatement(sql);
- pst.setString(1, txt_username.getText());
- pst.setString(2, txt_password.getText());
- pst.setString(3, txt_combo.getSelectedItem().toString());
- rs = pst.executeQuery();
- while (rs.next()){
- int Username =rs.getInt(1);
- Emp.empnum = Username;
- String username = rs.getString("username");
- Emp.empname = username;
- count = count+1;
- }
- String access = (txt_combo.getSelectedItem().toString());
- if(access =="Administrator,Admin,User"){
- if(count == 1){
- JOptionPane.showMessageDialog(null, "Success");
- MainMenu j = new MainMenu();
- j.setVisible(true);
- this.dispose();
- }else {
- JOptionPane.showMessageDialog(null, "The Username or Password you entered was incorrect!");
- }
- }
- }catch (Exception e){
- JOptionPane.showMessageDialog(null, e);
- }
- finally {
- try{
- rs.close();
- pst.close();
- }catch (Exception e){
- }
- }
- }`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement