• Post Reply Bookmark Topic Watch Topic
  • New Topic

Convert Orcale Long Raw to String  RSS feed

 
Bianca Hagen
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Bianca Hagen
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Couldn't imagine that I would be so simple.
Thank you!
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bianca Hagen
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx for the warning.
It was just a little bit too late:
I found out the hard way...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!