• Post Reply Bookmark Topic Watch Topic
  • New Topic

Convert BLOB-Field to String  RSS feed

 
heiner weilandt
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everybody,
my problem is to convert a blob-field to a string. i'm trying this, but i get only something i can't read like "[B@1a116c9"


 
Michael Fitzmaurice
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Heiner
The value you are printing ("[B@1a116c9") seems to be the result of printing the byte array, as opposed to the StringBuffer.
Have you tried passing the byte array to the String constructor? Use the overloaded constructor that takes a byte array as the first argument and the name of the character encoding as the second argument. Of course, this assumes that the BLOB really is a String, and that you already know its encoding.
Just out of interest, why is the String being stored as a BLOB? I would normally expect BLOBs to be used for strictly non-textual data.
Michael
[ October 27, 2003: Message edited by: Michael Fitzmaurice ]
 
heiner weilandt
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for answering, but i'm a beginner and i don't know what you mean. can you give me an code-example like mine code above ?
i use the CLOB not a BLOB, sorry! i use it, but i don't know the length of this field. it could be 1 byte or 10000 bytes...
heiner
 
Michael Fitzmaurice
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you just use the Clob.getSubString method? If this works, no need to mess about with the IO stream. For example:
 
heiner weilandt
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot!
it works with the substring!
it's so easy.....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!