private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        String user = t1.getText();
        String pass = new String(p1.getPassword());
        String username;
        pass = Md5Hash.passwordsalted(pass);
        if (user.isEmpty()) 
        {
            JOptionPane.showMessageDialog(this, "Please Enter your Username");
        }
        else if (pass.equals("b1f4f9a523e36fd969f4573e25af4540")) // check for empty string as password
        {
            JOptionPane.showMessageDialog(this, "Please Enter your Password");
        } 
        else
        {
            try {
                
                String query = "select username,password,type from users where username='" + user + "';";
                ResultSet rs = MyQueries.excQuery(query);
                rs.next();
                String DBuser = rs.getString("username");
                String DBpassword = rs.getString("password");
                String DBtype = rs.getString("type");
                if (DBuser.equals(user) && DBpassword.equals(pass)) 
                {
                    if (DBtype.equals("admin"))
                    {
                        username = DBuser;
                        MainPage a = new MainPage(username);
                        a.setVisible(true);
                        this.dispose();

                    } else if (DBtype.equals("issuer")) 
                    {
                        username = DBuser;
                        MainPageissuer a = new MainPageissuer(username);
                        a.setVisible(true);
                        this.dispose();
                    }
                } 
                else 
                {
                    JOptionPane.showMessageDialog(this, "Username or Password is Incorrect");
                }
            } 
            catch (SQLException | HeadlessException e) 
            {
                switch (e.getMessage()) {
                    case "Illegal operation on empty result set.":
                        JOptionPane.showMessageDialog(this, "No such Username Exists");
                        break;
                    case "ResultSet closed":
                        JOptionPane.showMessageDialog(this, "No such Username Exists");
                        break;
                    default:
                        logger.error("Error Description",e );
                        break;
                }
            }
            finally
            {
              myClasses.Connections.close(); // Close connection to prevent Database lock
            }

        }

    }//GEN-LAST:event_jButton1ActionPerformed