public String addUser() throws Exception {
        DBConnection dbcon = new DBConnection();
        Connection con = dbcon.connect();
        String check = "failure";
        String result=null;
        
        String query="SELECT COUNT(username) FROM users WHERE username='"+username+"';";
        PreparedStatement statement = con.prepareStatement(query);
        ResultSet rs = statement.executeQuery();
        
        if(rs.first()){
             result = rs.getString(1);
        }
        
        if(password.equals(confirmpassword) && email.equals(confirmemail)
                && result.equals("0")){
           query= "INSERT INTO users(username,password,firstname,lastname,email,address) VALUES('" + username + "','" + password + "',"
                   + "'" + firstname + "','" + lastname + "','" + email + "','" + address + "')";
           statement.executeUpdate(query);
           
           check = "success";        
        }

        if (check.equals("success")) {
            addMessage(new FacesMessage(FacesMessage.SEVERITY_INFO, "User Registration Successful!!!", null));
        } else if (check.equals("failure")) {
            addMessage(new FacesMessage(FacesMessage.SEVERITY_ERROR, "User Registration Failed!!!", null));
        }
        return check;
    }