Tim Nachreiner wrote:After trapping the error, I could see that the cause was due to referencing an invalid field in the table. Once I used the correct fieldname the error went away. Sorry for the confusion.
I'm still suprised this code worked because I thought the Date object needed to be instantiated somehow, not merely assigned a value. I thought I'd have to use something like
There are actually two Date classes, java.util.Date and java.sql.Date. Resultset.getDate() returns the java.sql.Date, but it is a child of java.util.Date and can be therefore used wherever java.util.Date can be. If you want to get rid of the java.sql.Date instance, you can do so the way you've shown (just be careful which version did you actually import), but why should you bother?