I would like to hide the UserSecurity menu point from users who have employee value in the database field. My code is:
String employee = "employee";
String SQL_USERSECURITY = "SELECT UserSecurity FROM user WHERE (UserSecurity = ?);";
String userSecurity = null;
try {
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/worker","admin","");
PreparedStatement stat = conn.prepareStatement(SQL_USERSECURITY);
stat.setString(1, userSecurity);
ResultSet rs = stat.executeQuery();
while ( rs.next() ) {
userSecurity = rs.getString("UserSecurity");
}
conn.close();
} catch (Exception e) {
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
}
JMenuItem Company = new JMenuItem(Labels.LIST_COMPANIES);
if (userSecurity.equals(employee)) {
Company.setVisible(false);
} else {
Company.setVisible(true);
}
May I ask your kind support to find out what can be the reason for the error?