This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to retrieve blob data in java

 
suresh venkat
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently the blob data in the table has text data (I think the data is in binary format) , can somone pls provide a sample code to retrieve blob data in text format.
 
Scott Selikoff
author
Bartender
Posts: 4033
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I haven't compiled this code and run it, but it seems like it should work. The blob gets dumped to the string total.
[ January 17, 2006: Message edited by: Scott Selikoff ]
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's also a CLOB type, just for this sort of thing.

Scott's code looks good, but if I could add one suggestion: find out the encoding used to turn text into binary in the first place and supply it to the InputStreamReader. Better safe than sorry:
 
payal agrawal
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the URL below:

How to store/retrieve image to/from SQLServer
http://www.java-tips.org/content/view/203/29/

How to store/retrieve PDF document to/from SQLServer
http://www.java-tips.org/content/view/845/29/

Here the column "data" has datatype of BLOB. You can save word document/image in form of BLOB data in database.
 
suresh venkat
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everybody , thanks for you response and the above solutions worked.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!