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());
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?
My typing error. My code was below. It still has error with the statement.
Date date;
date = (rcd.getDate(1)==null?"":rcd.getDate(1));
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".
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);
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).
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.