Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dealing with images/pictures

 
devayani Devasthali
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
payal agrawal
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the URL below:

How to store/retrieve image to/from SQLServer
http://www.java-tips.org/content/view/203/29/

Above URL contians an example with SQl server as database with column type as Blob
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic