Hey, I really need you guys help as I had been searching info on displaying blob images from database for weeks:(

I tried to add in the code that i think would display however it only display the path instead if the image.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<%@ page import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
				//Retrieve the id of the product selected by the user
				//the product id is sent via the URL as a parameter
				int ProductId = -1;
				String strProductId = request.getParameter("ProductId");
				if(strProductId != null) {
					//Convert from string to int
					ProductId = Integer.parseInt(strProductId);
				//Load the database driver
				//Create a connection to our database
		       	Connection con = DriverManager.getConnection("jdbc:mysql://localhost/peisze", "root", "");
				//create an SQL statement
		       	PreparedStatement ps = con.prepareStatement("SELECT * FROM products WHERE ProductId=?");
				//set the ID to be the id above
		       	ps.setInt(1, ProductId);
				//Execute and retrieve our result
		       	ResultSet rs = ps.executeQuery();
        	//if there is a result, rs.next() will be true
        	//else it will be false
			if(rs.next()) {
<legend>Product Information</legend>
<table border="0">
		<div align="left">Image: <%=rs.getBlob("ProdImage")+"\t" %></div>
		<td>Product Name: <%=rs.getString("ProdName")+"\t" %>

		<div align="left">Product Color: <%=rs.getString("ProdColor")+"\t" %></div>

		<div align="left">Product Description: <%=rs.getString("ProdDesc")+"\t" %></div>

		<div align="left">Product Price: <%=String.format("$%.2f",rs.getDouble("UnitPrice"))+"\t" %></div>

		<div align="left">Quantity: <%=rs.getString("Quantity")+"\t" %></div>


			else {
				//if no record is found, simply display a no record message
No record found.


This is the code that I used to display all those information of my products including the details of the products like name, color,etc...

However the outout is:


Product Information
Image: com.mysql.jdbc.Blob@78aa80  
Product Name: Yellow Beanie 
Product Color: Yellow 
Product Description: FEPPZĀ© label was derived from FEPPZ COMPANY and is inspired by the smart and casual style with a chic look for modern female! This beanie style headwear is vibrant in color that can lift one spirit up. 
Product Price: $30.00 
Quantity: 10

Can you guys provide examples of how to display the blob images from database?

Hope to receive you guys reply asap!:D

7 Years
Discussion Span
Last Post by peggie1990

But the code that I had input in is at the jsp page. Hmm do you have another example that show the details as well as information?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.