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 devayni
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
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.