aspose file tools*
The moose likes JDBC and the fly likes SQL Server image datatype Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL Server image datatype" Watch "SQL Server image datatype" New topic
Author

SQL Server image datatype

Dan Eichler
Greenhorn

Joined: Dec 01, 2011
Posts: 6
I'm a little newish to java, but really new to sql server and datatype image.

I am trying to extract files from the database and store them locally on the computer. I have retrieved the image contains from the column with rs.getBlob, and have saved them to the system with the following code:

BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fileName));
bos.write(blob.getBytes( 1, (int) blob.length()), 0, (int) blob.length() );

This does save the file, but I can't open the file no matter what I change the extension to. The kicker is that I don't know what each file is suppose to be, the database does not contain the names of the files either.

Dan Eichler
Greenhorn

Joined: Dec 01, 2011
Posts: 6
So it ended up being the way the data has been stored into the database. It's converted to another proprietary format. I have tested my code on another table in the database that has pdf's stored as blobs and those work fine.

Dan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQL Server image datatype