• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Retrieve image from mysql database to table created in jsp page  RSS feed

 
H.Amit Kumar
Greenhorn
Posts: 4
C++ Java Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here in this code I am trying to retrieve MySQL database contents such as "images, id, product details " into table created on JSP page. But on compilation it shows: "  Unknown column 'id' in 'where clause'  " message. I have tried a lot but, unable to  retrieve image  from database to table created in JSP page.The image stored in database is Blob image. Can anyone guide me how to retrieve images one after one in table from database to JSP page. Thanks in advance.


-------------------------------------------------------------------------------
Product-IdProduct ImageProduct NameDiscountTotal Price
1Blob imageARM0.527000.00
2Blob imageArduino0.12300.00
3Blob imagePIC microcontroller052500.00

--------------------------------------------------------------------------------
Message: Exception:Unknown column 'id' in 'where clause'
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37395
531
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your table, the column is named "Product-ID", but in the SQL, it is "id". These need to be the same.

Also, note that having Java code (like JDBC) in a JSP is a really old/bad practice.
 
Dave Tolls
Ranch Foreman
Posts: 3001
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Jeanne says, you don't have an 'id'column in your database table.  You haven't shown us the table itself, but you later try and extract a prod_id from result set, so maybe that's the actual name?

As for the image, you cannot place the image on the page as a single action like this.
HTML does not work like that.
What you need to do is place an <img> tag whose src attribute points to a servlet on your server whose job is to return images.  That servlet will accept the prod_id(?) in the request and pull the BLOB from the db for that row and stream it back.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!