For a school exercise I need to get some information from a database.
We need to scan a RFID card and lookup in the database. But when I try to print out the line in the IDE I get more results than I want.
The RFID tag something like: 2R KL MZ 89 and if I try to get it from the database I get: Access Granted. (because that is the record that is right) and Access Denied. (because that is the record which is wrong.
Long story short: How do I get ONLY Access Granted. when the tag is correct and ONLY Access Denied.
Code:
while (rs.next()) {
String number = rs.getString("number");
if (number.equals(key)) {
System.out.println("Access Granted.");
} else {
System.out.println("Access Denied");
}
}
Table:
My table is only id, which is auto increment, and the other row is called number which contains two records: the right tag and the wrong one.