This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes dealing with images/pictures Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "dealing with images/pictures" Watch "dealing with images/pictures" New topic

dealing with images/pictures

devayani Devasthali
Ranch Hand

Joined: Aug 25, 2005
Posts: 40
Hello All,
I am developing a simple web application. One of my tables contains photographs/images/pictures.
can anybody pls tell me abt how to read them from table also, how to write them also.I am using access / mysql database with tomcat 5
thanx in advance
with regards
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Sometimes people just store the path to the picture in the database.

If you want to store the picture itself, you can use column type BLOB. How you work with BLOB can depend on your DBMS and any support you're getting from frameworks you may be using (Hibernate makes it easy). With raw JDBC, you can insert a row using a PreparedStatement and its setBinaryStream method (or setBytes, but I haven't tried that). In the other direction, to get the data out of a ResultSet, you can use getBinaryStream (or getBytes, but I haven't tried that either), or getBlob and Blob methods.

There is no emoticon for what I am feeling!
payal agrawal
Ranch Hand

Joined: Oct 11, 2005
Posts: 44
Look at the URL below:

How to store/retrieve image to/from SQLServer

Above URL contians an example with SQl server as database with column type as Blob
I agree. Here's the link:
subject: dealing with images/pictures
It's not a secret anymore!