aspose file tools
The moose likes JDBC and Relational Databases and the fly likes storing images in database and retreiving it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "storing images in database and retreiving it" Watch "storing images in database and retreiving it" New topic

storing images in database and retreiving it

salamath ahamed

Joined: Aug 11, 2003
Posts: 7
how to store an image in database and how to retrieive it ,please help

Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
There are two approaches:
1) Store the image file into a BLOB field
2) Keep the image in the filesystem and only store the location into the database

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300

My Opinion. Go with Lasse's 2nd option of storing the image on the file system and storing the location in the database. DB Performance can really decrease when storing Binary data in a table.
However, if you would prefer to store the image itself in the database...

I don't know if this is syntactically correct. But in escense I believe the thoery is correct. I just kind of threw this together.

GenRocket - Experts at Building Test Data
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: storing images in database and retreiving it