Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void LoginButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoginButtonActionPerformed
- String sqlquery= "select id,username,password,division from users where (username = ? and password = ? and division = ?)";
- try{
- UsernameField.setText("");
- PasswordField.setText("");
- int count = 0;
- pst = conn.prepareStatement(sqlquery);
- pst.setString(1, UsernameField.getText());
- System.out.print(UsernameField.getText());
- pst.setString(2, PasswordField.getPassword().toString());
- System.out.print(PasswordField.getPassword().toString());
- pst.setString(3, rankCombo.getSelectedItem().toString());
- rs = pst.executeQuery();
- while(rs.next()){
- count ++;
- emp.empId = rs.getInt(1);
- }
- String access = rankCombo.getSelectedItem().toString();
- if (access=="Admin"){
- if (count == 1){
- JOptionPane.showMessageDialog(null, "Succesfully loged as an admin");
- AdminsPanel g = new AdminsPanel();
- g.setVisible(true);
- this.dispose();
- }else {
- JOptionPane.showMessageDialog(null, "Your Username and Password is not valid");
- }
- }
- }catch(Exception e){
- JOptionPane.showMessageDialog(null, e);
- }finally{
- try{
- rs.close();
- pst.close();
- }catch(Exception e1){
- JOptionPane.showMessageDialog(null, e1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement