0

i can't understand what problem with the statement below. No error in sql statement and connection.

Date dt;

dt = (rs.getDate(1)==null?"":rs.getDate(1.trim());

4
Contributors
5
Replies
6
Views
9 Years
Discussion Span
Last Post by jwenting
0

What is that trim suppossed to be doing?

a number entered like that is an int, which can't be trimmed, and getDate returns a Date, which can also not be trimmed (if that was what you meant). Neither of those are Strings, which is the Class that actually has that method.

What exactly are you trying to do?

0

My typing error. My code was below. It still has error with the statement.

Date date;
date = (rcd.getDate(1)==null?"":rcd.getDate(1));

0

hardly surprising. If "rcd" is null you get an exception.
thus the error in your code (or at least that one) is not on that line but elsewhere, where you fail to fill "rcd".

0

I think that this shouldn't even compile:

Date date;
date = (rcd.getDate(1)==null?"":rcd.getDate(1));

Because if rcd.getDate(1)==null then the expression wil return an empty String: "". But date is type Date:
Plus, I think that the parenthesis should be like this:

date = (rcd.getDate(1)==null)?"":rcd.getDate(1);

0

it indeed won't compile. but even if it did it wouldn't work if he has a problem getting a resultset and ignored it (as so many kids do).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.