This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving blob data in java

 
sutha kavi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

My scenario is : Retrieving the long blob data from mysql database in java and pushing those data into excelsheet.Anybody have idea about this? Please help me.........
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are you stuck? You get the Blob from your ResultSet, get a binary stream from the Blob, and write the data to a file. You don't have to convert it, do you? I mean, it's already stored in Excel format, right?
 
sutha kavi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Blob data in Db is not in excel format.I read the datas from excel ,validate it and then insert those datas into table. While retrieving , I just get data only(binary format).Also I am using Ibatis.When I used Blob type to retrieve the data, ibatis exception was thrown.how i convert this binary(byte[]) data to string?
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, we're making progress. If the binary data isn't in Excel format, what format is it in?

The String class has a constructor that takes a byte array, which converts the bytes to chars using the default character encoding for your platform. That may be all you need.
 
sutha kavi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried for the method that you have told i.e., string constructor with byte array as argument.But the ouput is in binary format only
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, let's back up. You get data from a BLOB. You want that data to become an Excel spreadsheet, or possibly a String. However, you don't know, or at least haven't told us, what form that data starts in. You really need to figure that out as your first step.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still trying to figure out if this question has anything to do with this one: http://www.coderanch.com/t/541369/Struts/Excel-File-opening
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic