Link to home
Start Free TrialLog in
Avatar of piou
piouFlag for Greece

asked on

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?

ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oops

s = s.substring(0);

Avatar of jimmack
jimmack

s = s.substring(0, 1);

;-)
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 ;-)
Avatar of piou

ASKER

My worry about CHAR is implications when reading/writing using international locales. Anyway, by trial and error I guess :)  Thanks.
8-)

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.