• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I insert an image into a database from a servlet?

 
Aditya Vasudeva
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a web page in which i have a browse button which selects an image on my local hard disk. I have a submit button which submits the file to the server.

How do I insert this image into a BLOB attribute in a table of my database.
The data type of the image specified in the database is type BLOB.

Please specify the code if possible.

Please help.
Thank You.
[ October 26, 2008: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
People here are happy to help you with your code, but are unlikely to write it for you. What have you got so far?
 
Aditya Vasudeva
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the form I am using to submit the request to the database.




Here is my servlet. It takes in the url of the image on my hard disk in the File fBlob. Is this code correct? It doesnt work when I click the submit button. It throws an SQLException giving the column name in which I am trying to insert the BLOB i.e. PHOTOGRAPH.



Please help me now...
Thank You
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34211
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The SQL Exception would be due to an invalid SQL statement.


Here you specify two column values but only one column name. You'll need to add a second column name to synch things up.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic