0

I am developing an application using Java, my application would be accessed by number of different users simultaneously and the database resides in a central server. The access of the database from remote server is handled by just giving the appropriate IP of the server in the Hibernate configure file.

My question is, I have to store a picture regarding each user of the database, I heard that storing the image in the database and retrieving it from the database is not advised and has negative impact on the performance. Is it so?

What are the other possible ways i can implement this? What is the best way to do it?

halfer
  • 19,824
  • 17
  • 99
  • 186
sasidhar
  • 7,523
  • 15
  • 49
  • 75

1 Answers1

2

well, store the images at app server in file system and save it's reference to users table's image_location column. refer: Photo storage for web app


Side Note: If you have multiple app server, better store the files at a shared location accessible to all the app server in indentical manner. It's not a good idea to store file in database.


As indicated by @sasidhar, here is what I would do:

  1. Make a central image server with Unix OS on it. Will make sure it has fixed IP.
  2. In your app, use JSch to secure copy file from client machine to a dedicated directory at the server
  3. Update the users table's image_location with relative path of the image from "/"
  4. When viewing, I will check the relative path of the user and fetch it again using JSch secure file tranfer protocol.

By the way, setting up a FTP could be a better alternative.


Why should you not use DB as file storage? See here: Storing Images in DB - Yea or Nay?

Community
  • 1
  • 1
Nishant
  • 54,584
  • 13
  • 112
  • 127
  • This is not a web app, i essentially want an .exe file for each the users accessing the remote database, thats part of my requirement, other wise i would have conveniently chosen web-technologies. In java how do we get files stored on the server ? Besides i am not using java's networking capabilities... – sasidhar Dec 26 '10 at 18:50
  • Is it like a GUI tool to view data-base? Users will download this application and use it to connect to remote DB server; and you want them to have a profile image? – Nishant Dec 26 '10 at 18:58
  • @Nishant Its a GUI application for different administrative authorities in a college, and they manipulate the students data in different ways and each student has a pic... – sasidhar Dec 26 '10 at 19:01
  • @sasidhar I have updated the answer. In a way or other, you will have to use Java networking capability because the images are stored at remote machine in the network. You may lure to save file in DB, but I am always advised against it. – Nishant Dec 26 '10 at 19:16
  • here. this explains http://www.4guysfromrolla.com/articles/120606-1.aspx I usually keep in file-system for creating multiple version and to keep DB size under control. Big images say more than 500KB per row may inflate your DB size. And above all, performace. But since I never tried storing files in DB, I do not have first hand experience. – Nishant Dec 26 '10 at 19:42
  • @sasidhar If you just Google, you'll find lot of discussions. This is a good discussion, please read: http://stackoverflow.com/questions/3748/storing-images-in-db-yea-or-nay – Nishant Dec 26 '10 at 19:48