This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Problem in converting RAW data type to String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problem in converting RAW data type to String" Watch "Problem in converting RAW data type to String" New topic

Problem in converting RAW data type to String

satya kiran
Ranch Hand

Joined: Nov 07, 2000
Posts: 52
I retrieved an Oracle RAW data type by
byte b[]= statement.getBytes(n).
Somehow, I need to have the String represtation of this field, and later also need to convert back to the byte[].
When I use new String(b), it just gives me some unreadable symbols.
While at the same time, I know this field have a value like: D1EE971C4852A356E03311227403A356.
I tried using
Byte[] message = rs.getBytes("MessageID");
String str = new String (message); (I also tried using new String(message, "UTF-8"))
Thanks in advance for the help!
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32481

Where did the raw data come from originally. Often this problem occurs when there is binary (non-character) data in the bytes.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Problem in converting RAW data type to String
It's not a secret anymore!