aspose file tools*
The moose likes I/O and Streams and the fly likes Retrieving blob data in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Retrieving blob data in java" Watch "Retrieving blob data in java" New topic
Author

Retrieving blob data in java

sutha kavi
Greenhorn

Joined: Jun 10, 2011
Posts: 14
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

Joined: Oct 01, 2001
Posts: 2854
    
  11

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

Joined: Jun 10, 2011
Posts: 14
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

Joined: Oct 01, 2001
Posts: 2854
    
  11

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

Joined: Jun 10, 2011
Posts: 14
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

Joined: Oct 01, 2001
Posts: 2854
    
  11

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
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
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


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retrieving blob data in java