I am building a program which checks the roles of users. When a button gets pressed it uses the userID to query the role/group table of our database. If a person is not in the role/group tables then they are a requester. I have the following code, and was wondering why the last else if
statement is not working.
When we set a person to be a requester, they are literally removed from the role/group tables. So the resultset
should be empty. Right?
ResultSet rs = stmt.executeQuery(getRolesQuery2.toString());
try
{
boolean empty = true;
while (rs.next())
{
empty = false;
userRole = rs.getInt(1);
userGroup = rs.getInt(2);
System.out.println("The Users Current Role/Group is: " +userRole+ "/" +userGroup);
if(userRole == 4 && userGroup == 1)
{
userRoleLbl.setText("The User Role/Group is: " +userRole+ "/" +userGroup+ " NDS Administrator");
}
else if(userRole == 1 && userGroup == 3)
{
userRoleLbl.setText("The User Role/Group is: " +userRole+ "/" +userGroup+ " Privacy Administrator");
}
else if(userRole == 1 && userGroup == 5)
{
userRoleLbl.setText("The User Role/Group is: " +userRole+ "/" +userGroup+ " Security Administrator");
}
else if(userRole == 1 && userGroup == 7)
{
userRoleLbl.setText("The User Role/Group is: " +userRole+ "/" +userGroup+ " ORD Administrator");
}
else if(userRole == 1 && userGroup == 9)
{
userRoleLbl.setText("The User Role/Group is: " +userRole+ "/" +userGroup+ " OEF-OIF Administrator");
}
else if(userRole == 1 && userGroup == 11)
{
userRoleLbl.setText("The User Role/Group is: " +userRole+ "/" +userGroup+ " Surgery Administrator");
}
else if(userRole == 1 && userGroup == 13)
{
userRoleLbl.setText("The User Role/Group is: " +userRole+ "/" +userGroup+ " Capri Administrator");
}
else if(userRole == 3 && userGroup == 15)
{
userRoleLbl.setText("The User Role/Group is: " +userRole+ "/" +userGroup+ " DART Super User");
}
//TODO: Add some handling for if the role/group is not present which means they are a requester
else if(empty)
{
userRoleLbl.setText("The User is a Requester");
}
}