开发者

How can i store and retrieve images from a database?

I am creating a website as a mini project w开发者_JAVA百科hich will be used to sell various products. In the website i intend to give detailed info about the products which will be retrieved from the database. I am using Servlets and JSP as the serverside and pointbase DB. So i'll be using JDBC to connect to the DB. Please tell me how insert images into the DB and give sample code for the same. Also give details how to retrieve them.

Thanks you all in advance..


Wouldn't it be easier to store images on a file system and store the paths in the database?


You can insert binary data into databases that support binary fields (usually called BLOB).

But that isn't such a great idea - store them in your server and store the path to them on the database instead.


You should convert the file to a BLOB and then store it in the database as such, this will then make easy retrieval details below...

http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/exercises/BLOBPut/help.html


I still think that it is better to store images in a database. It is more efficient.

Here is a good tutorial of how to do it: http://tutslink.blogspot.com/2012/04/jsf-displaying-images-from-database-in.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜