When trying to select data from a table in Access, I get a java.lang.NullPointerException errror. The code works for other tables though.
This is the code that works:
//cun is passed as a parameter
try {
ResultSet rs = db.queryTbl("SELECT * FROM tblCustomer WHERE CustomerUName = '" + cun + "';");
while (rs.next()) {
cusFName = rs.getString("CustomerFName");
cusSName = rs.getString("CustomerSName");
}
rs.close();
} catch (SQLException ex) {
Logger.getLogger(Customer.class.getName()).log(Level.SEVERE, null, ex);
}
This is the code that doesn't work:
//dun is passed as a parameter
try {
ResultSet rsDri = db.queryTbl("SELECT * FROM tblDriver WHERE DriverUName = '" + dun + "';");
while (rsDri.next()) {
driFName = rsDri.getString("DriverFName");
driSName = rsDri.getString("DriverSName");
}
} catch (SQLException ex) {
Logger.getLogger(Driver.class.getName()).log(Level.SEVERE, null, ex);
}
The error takes me to the line:
ResultSet rsDri = db.queryTbl("SELECT * FROM tblDriver WHERE DriverUName = '" + dun + "';");
Please can you help?