I have my static analysis utility configured to ignore magic numbers above a certain threshold. (I think it is 10 or 15) to avoid the
JDBC code being triggered. I don't like using the column names because if they change in the SQL, I have to remember to change them in the get/set methods. For the rare occasions where my JDBC code uses a ton of columns, I configure the static analysis tool to suppress the errors.
In your first example with the zip code, the tool is right. You do have a "magic number" in the code. You didn't work around it - you fixed a problem. It's traditional to use a real constant for this like:
private static final int ZIP_LENGTH = 11;