| Author |
Reading & Updating SQL Server Image type
|
Mitchell Baron
Greenhorn
Joined: Jun 09, 2008
Posts: 6
|
|
Hello, I am trying to create a Java method that somehow reads a SQL Server image type and returns either a blob, byte[] or whatever else would make sense so that I can display the image on a web page. I have seen other posts about this but am still not sure how to get this to work. Here is a small example of trying to get the image. It does not have to return a byte type, just whatever would work for displaying the image in a jsp page. I also am not sure how to prevent issues if the image column is null. Any suggestions? Many thanks! Mitchell
|
 |
Gavin Tranter
Ranch Hand
Joined: Jan 01, 2007
Posts: 333
|
|
|
Instead of storing the image itself why not store a path to the image?
|
 |
Mitchell Baron
Greenhorn
Joined: Jun 09, 2008
Posts: 6
|
|
|
I don't have a choice unfortunately because the images already are stored in the database otherwise I gladly wouldn't have done that. Is there an effective way to extract them with Java/JSP?
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16480
|
|
|
Have you tried writing that array of bytes to a file (with a suitable name denoting the type of image, JPG or PNG or whatever)? Does that produce a usable image file?
|
 |
Dan Walin
Ranch Hand
Joined: Nov 11, 2003
Posts: 109
|
|
On your question about how to prevent issues if the column is null, I do this type of thing: In other words, I always check if the column is null before deciding how to process it.
|
 |
 |
|
|
subject: Reading & Updating SQL Server Image type
|
|
|