I have combo box and two type of employee in my db I want to display full time emplyee in the combo box however when I tested the code I this line is executed test = conn.prepareStatement("select * FROM Employee WHERE EmployeeType = " + "'" + "Part Time" + "'");
and not the first line. I have no I idea what is wrong with the code I'm sure that it is correct
public void EmployeeCombo() {
String EmployeeType = "Full Time";
try {
PreparedStatement test = null;
ResultSet rs;
Connection conn = ConnectionManager.getConnection();
if (EmployeeType.equals("Full Time")) {
test = conn.prepareStatement("select * FROM Employee WHERE EmployeeType = " + "'" + "Full Time" + "'");
} else {
test = conn.prepareStatement("select * FROM Employee WHERE EmployeeType = " + "'" + "Part Time" + "'");
}
rs = query.executeQuery();
while (rs.next() != false) {
String f = rs.getString("first");
String l = rs.getString("last");
Employee emp = new Employee(f, l);
ComboEmployee.addItem(emp.full());
}
} catch (SQLException | ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
}
}