File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Retrieving image from database - getBlob? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Retrieving image from database - getBlob?" Watch "Retrieving image from database - getBlob?" New topic
Author

Retrieving image from database - getBlob?

Stefan Renemeister
Greenhorn

Joined: Sep 26, 2009
Posts: 13
Hi there,

I am performing my first steps in java JDBC, and as an exercise try to show some images from a mysql database.
The thing below runs, but doesn't show my photo's. (it does show the id's however).
It returns the following error:

SQLException: Column Index out of range, 0 < 1.
SQLState: S1009
VendorError: 0


What am I doing wrong? And more important, what is the proper way to show my photo? Any help is greatly appreciated!

Stefan Renemeister
Greenhorn

Joined: Sep 26, 2009
Posts: 13
Duuuh, forgot the quotes in the columnname..

Should have been:

instead of:


Ok, well here's the following question:

my result of above code is:

1
com.mysql.jdbc.Blob@84da23
2
com.mysql.jdbc.Blob@d3d6f


I'd like to see the actual pics, instead of the data.. How can I transform this into a picture?
Stefan Renemeister
Greenhorn

Joined: Sep 26, 2009
Posts: 13
Anybody any advice?
 
 
subject: Retrieving image from database - getBlob?
 
Similar Threads
Accessing variable from another method
BLOB(image) -> ByteArrayOutputStream -> display on screen
unable to establish a connection betwen JDBC and MySQL server using a java class.
oracle connection with jdbc
Null Pointer Exception