aspose file tools
The moose likes Java in General and the fly likes Convert Orcale Long Raw to String Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Convert Orcale Long Raw to String" Watch "Convert Orcale Long Raw to String" New topic
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...
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Convert Orcale Long Raw to String
 
Similar Threads
How to get byte[] from the Image
Converting Document to String
How to get byte[] from the Image?
DOM to string
convert a String to Long