File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving blob data in java

 
sutha kavi
Greenhorn
Posts: 15
  • 0
  • 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: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 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
  • 0
  • 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: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 0
  • 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
  • 0
  • 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: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 0
  • 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
Pie
Posts: 42966
73
  • 0
  • 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
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic