I don't think the code is doing what you intended it to do.
1.
The line "if(rs != null){System.out.println("Not Null");}" accomplishes nothing
. The only case in which rs would be null, would be if there was an exception thrown. In that case, the code would just jump to the exception handling block anyways. So just remove this line
2.
This line works fine: "if(!rs.next()){System.out.println("I'm not next");}". It checks to see if there are any results, and moves the cursor to the first row.
3.
This line is not doing what you think: "while(rs.next()){java.sql.Date date1 = rs.getDate("date1");}". In this line you are saying, if there are rows, then process the results...starting at
row 2! You never process row 1 because by the time you get to processing your code you have called rs.next() twice, moving you to the second row in your resultset. If there is only one row (and this should be your case), You will get -->it prints "Not null" and not next.
Resolution: something like this:
Does this do what you wanted? If not, what were your intentions?
Jamie
[This message has been edited by Jamie Robertson (edited November 26, 2001).]