This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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

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'
author & internet detective
Posts: 39129
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.
Master Rancher
Posts: 3887
  • 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.
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!