| Author |
Convert Orcale Long Raw to String
|
Bianca Hagen
Ranch Hand
Joined: Apr 28, 2004
Posts: 41
|
|
Hi, I have an Oracle database with a Long Raw attribute. I want to show the contents of this attribute as readable text (like a String). Can anyone tell me how to retrieve this attribute from the resultset (rs.getString?) and how to convert it? Thanx
|
 |
Ko Ko Naing
Ranch Hand
Joined: Jun 08, 2002
Posts: 3178
|
|
You have to use resultSet.getBytes(columnIndex) to retrieve the values from Oracle's LONG RAW attribute and then use new String(thoseBytes) to create the string that you want... That's it... You'll get the string that those bytes represents...
|
Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
|
 |
Bianca Hagen
Ranch Hand
Joined: Apr 28, 2004
Posts: 41
|
|
Hi, Couldn't imagine that I would be so simple. Thank you!
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
A word of warning - check that your byte array is not null. The JavaDoc for this constructor does include this often overlooked bit of advice:
The behavior of this constructor when the given bytes are not valid in the default charset is unspecified
And nulls are not usually valid.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Bianca Hagen
Ranch Hand
Joined: Apr 28, 2004
Posts: 41
|
|
Thanx for the warning. It was just a little bit too late: I found out the hard way...
|
 |
 |
|
|
subject: Convert Orcale Long Raw to String
|
|
|