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

storing images in database

 
jyotsana dang
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do we store gif images in sql server and how do we retrieve them?
is it useful to store images in the sql server.
thanks
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jyotsana,
You can store images as a BLOB. You would get/set them using JDBC. There are methods for byte[], binary stream and blob.
There are some reasons for storing images in a database. But, if they are images that are part of a web page, you are often better off storing them on a web server.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it useful to store images in the sql server.
My 2 cents. It depends. If your application is image intensive meaning your application that depends on the Database is primarily an imaging storage/retreival app of some sort which would mean that the majority of the data in your database is going to be binary data, then sure. There are also ways to optimize performance on some DB's for image storage/retreival.
On the other hand, if you application is primarily data centric and just stores a few images here and there (I would say 60% data, 40% images or less) then storing images along side data in a Database can really hurt your performance. In this situation it would be best to store the images somewhere on the harddrive and simply store reference/location data in the database of where the image is located on disk.
Do you like how that really didn't answer your question?
As far as "how to.." I found this on Google. It should get you started.
 
Jason Steele
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My two cents...with interest:
The two cents:
I have never been a fan of storing images in a database. Images can really hamper db performance and increase db size tremendously. IMHO, just store the location and filename in the image field like Gregg said and then use that to pull image from file location in your web project or app.

The interest:
Opinions are going to vary on this subject. Some will argue that it is better to store all record data in a centralized location. Others, like me, say that storing a reference to the image is worth the extra effort if it will improve performance. Most users do not know where data is stored, and for the most part don't care, as long as the data is accessible.

Good luck in your decision and I too probably did not help you. :roll:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic