Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting from BLOB to string

 
Shane Lee
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Im selecting back from oracle database a blob value which is my xml message.
My code to transform the blob to a string is:


This does work, Im just wondering if this is the most efficient/correct way of coverting the byte array to a string?
 
Scott Selikoff
author
Saloon Keeper
Posts: 4015
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some drivers support getString() on blobs although its risky to use because of encoding. In short, blob code is never that pretty. In your case, it does seem a little long. There's a number of examples available via Google: http://www.google.com/search?q=jdbc+convert+blob+to+string

I'm recommend trying the simplest one with your JDBC driver and goes whatever works. Keep in mind, string encoding can get ugly for reading blob data.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic