File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes storing images in database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "storing images in database" Watch "storing images in database" New topic
Author

storing images in database

jyotsana dang
Ranch Hand

Joined: Sep 26, 2003
Posts: 135
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
134

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

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.


GenRocket - A Test Data Generation Platform
Jason Steele
Ranch Hand

Joined: Apr 25, 2003
Posts: 100
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:


An egg is a chicken's house!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: storing images in database
 
Similar Threads
images inserting
images
Storing image in xml
storing images in database
Images in Microsoft SQL server 2005