Results 1 to 1 of 1
Thread: Resultset comparision method
- 07-27-2011, 11:51 AM #1Member
- Join Date
- Jul 2011
- Rep Power
Resultset comparision method
I was wondering why when I was fetching a sql select sentence (inside RowMapper prodecude inside jdbcTemplate ), the condition I set for avoid null exception didn't work.
I mean, when having if sentence like:
if (rs.getTimestamp("bornDate") == null )Java Code:
if (rs.getTimestamp("bornDate").equals(null) )
While debugging, condition was always false with equals even if the result set got null value. Changing it by == worked like a charm.
¿Isn't supposed while comparing objects we should use equals instead of == ?.
I can understand the reference of resultset will not be null, but the value itself instead which is what I was searching for (in order to do the if sentence).
I am confused
Some advice will be helpful , thanks.
- By vimalaranjan in forum New To JavaReplies: 6Last Post: 05-19-2011, 02:27 PM
- By Anjaneyulu in forum Advanced JavaReplies: 15Last Post: 02-24-2010, 03:32 PM
- By rons_sacramental in forum New To JavaReplies: 7Last Post: 10-15-2009, 05:15 AM
- By suprabha in forum Advanced JavaReplies: 14Last Post: 08-01-2008, 02:49 PM
- By Java Tip in forum Java TipReplies: 0Last Post: 02-14-2008, 10:50 AM