• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Saving images in database from servlet

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am developing a shopping cart webapp , i want to know that ,

how to add image in database using servlet as i want to insert images for various products ..

Thanks

Nikesh Shah
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So which part are you having an issue with? The servelt part or the JDBC part? If it's the latter, then I'll move this to the JDBC forum. Let us know.
 
niku shah
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Actually i have issue with both the parts servlets and jdbc....

would it require any file uploading code or just JDBC insert statement ?
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We can't guess what it is you need to you. Please be detailed in your posts.

Where is the image file coming from?
 
Ranch Hand
Posts: 691
Mac
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

would it require any file uploading code or just JDBC insert statement ?



It seems you are not clear about the technology. Since you are a gujarati would like to give some details.

File uploading is different then JDBC insert statement.
File upload gives you data in binary stream.
For storing image in database your database should support blob type.
Moreover it is not advisable to store many images in database, best solution is to store it in a file system(ie. on your machine) and store the path detail in DB.

For file uploading and storing in the database you can use struts framework instead of writing everything by using servlet.

Hope this helps.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Jignesh pointed out, it is not advisable to store image files in database, especially if you are using those images to be rendered on your web applications.

It is better to use a file system and refer to it. It will also be easier to modify the images. It will be more manegable if you want different images to be displayed for specific locales / user groups.

However, if you are allowing the user to upload files to your webapp, then you might need some secure file system to store it. Your webapp may either create a sub directory under that file system for each user or store all the files in the same location.
 
niku shah
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all for the above responses...
 
Willie Smits can speak 40 languages. This tiny ad can speak only one:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic