Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void loginDatabase(){
- //Checks to see if Login is Administrator and then sends him to his respective location
- String userName1 = Usr1.getText();
- String passWord1 = Pass1.getText();
- try{
- String query1 = "select * from LoginManager where Username='"+userName1+"' and Password='"+passWord1+"' and Position=?";
- PreparedStatement pst1 = conn.prepareStatement(query1);
- ResultSet rs1 = pst1.executeQuery();
- if (rs1.next()){
- String add1 = rs1.getString("Username");
- usernameCon1.setText(add1);
- String add2 = rs1.getString("Password");
- passwordCon1.setText(add2);
- String add3 = rs1.getString("Position");
- positionCon1.setText(add3);
- }
- pst1.close();
- rs1.close();
- }catch(Exception e){
- JOptionPane.showMessageDialog(null, e);
- }
- }
- private void login(){
- loginDatabase();
- if (usernameCon1.getText().matches(regex) &&passwordCon1.getText().matches(Pass1.getText()) && positionCon1.getText().equals("Administrator")){
- Admin();
- usernameCon1.setText("");
- passwordCon1.setText("");
- positionCon1.setText("");
- Usr1.setText("");
- Pass1.setText("");
- }
- else if (!usernameCon1.getText().isEmpty() && !passwordCon1.getText().isEmpty() && positionCon1.getText().equals("Manager")){
- }
- else if (!usernameCon1.getText().isEmpty() && !passwordCon1.getText().isEmpty() && positionCon1.getText().equals("Teacher")){
- }
- else {
- JOptionPane.showMessageDialog(null, "Invalid Login", "Invalid Login", JOptionPane.ERROR_MESSAGE);
- }
- }
Add Comment
Please, Sign In to add comment