Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BLOB retrieval

 
ravi daya
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34410
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Wei Dai
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"));
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic