File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes BLOB retrieval Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "BLOB retrieval" Watch "BLOB retrieval" New topic
Author

BLOB retrieval

ravi daya
Greenhorn

Joined: Jun 27, 2012
Posts: 3
I am saving a string into oracle db and the data type is blob, but when i retrieve the blob values i dont get the desired string back please find the code for both for storage and retrieval



the code used for retrieval



I am not able to retrieve the string it returns some weird characters
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30789
    
157

Ravi,
Blob is for binary data. Clob is for character data. Since you have character data, you are likely getting the binary equivalents. I recommend you switch to Clob/character stream.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Wei Dai
Ranch Hand

Joined: Jun 22, 2005
Posts: 86
ravi daya wrote:I am saving a string into oracle db and the data type is blob, but when i retrieve the blob values i dont get the desired string back please find the code for both for storage and retrieval
I am not able to retrieve the string it returns some weird characters
byte[] byteArray = stringToByte.getBytes();
System.out.println(new String(blob.getBytes()));

You can try
byte[] byteArray = stringToByte.getBytes("ISO8859_1");
System.out.println(new String(blob.getBytes(),"ISO8859_1"));
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BLOB retrieval