JDBC: how to read CHAR and DATE data

What is the best way to read Oracle's CHAR data? I don't think there is a relevant ResultSet method... Would it be a getString? (If so, is it guaranteed that the string is of length==1?)

Also, when getting a java.sql.Date value, how can I put it in a java.util.Date?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

getString is fine. You can make the String have length one come what may

if (s !=null && s.length() > 1)
    s = s.substring(1);

You can simply cast a sql Date to its supertype (java.util.Date)

java.util.Date d = (java.util.Date)_d;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

s = s.substring(0);

s = s.substring(0, 1);

OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

or if you just want the "char" value:

char c = s.charAt(0);
>>s = s.substring(0, 1);

Yes - not woken up properly yet ;-)
Same thing I did with JList.add() last night ;-)
Not that it would have done you much good if you *had* got it right - for obvious reasons ;-)
piouAuthor Commented:
My worry about CHAR is implications when reading/writing using international locales. Anyway, by trial and error I guess :)  Thanks.

It's the field in the db you should be concerned about, not Java. You should be able to store stuff in the db as Unicode. Java will handle it thereafter.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.