I got a method to get an integer from a MySQL table
public int getAddressID(String postcode) throws SQLException {
String q = "SELECT PK_ADDRESS_ID FROM tbl_addresses WHERE postcode =" + "\"" + postcode + "\"";
System.out.println(q);
ResultSet rs = executeSearch(q);
int pc = 0;
while (rs.next()) {
String str = rs.getString("postcode");
pc = Integer.parseInt(str);
}
System.out.println(pc);
return pc;
}
The query seems fine but somehow when I initialize some variable and use this method, I get the error Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "". Am I missing anything? Thanks for any help!