I can't display BLOB
image that I have in mysql
saved. I have beans, jsp. I use 3multy-tier architecture, I want to display all the products with the picture.
In acceesor:
try {
Connection cn = getVla().getConnection();
String sql = "SELECT * FROM products";
PreparedStatement pst = cn.prepareStatement(sql);
ResultSet rs = pst.executeQuery();
ArrayList<products> ls = new ArrayList<products>();
while(rs.next()) {
products s = new products();
s.setPk(rs.getLong("pk"));
s.setName(rs.getString("name"));
s.setPrice(rs.getDouble("price"));
s.setPic(rs.getBlob("pic"));
s.setComments(rs.getString("comments"));
ls.add(s);
}
return ls;
}
In products:
public Blob getPic() {
return pic;
}
In main.jsp
<%=
List<products> product = bean.getproducts();
%>
<h1>Product: </h1>
<%
for(products c : product) {
%>
From <%= c.getName()%> <br/>
<%= c.getPic()%></b><br/>
<b><%= c.getPrice()%> </b><br/>
<%= c.getComments()%>
<hr/>
<%
}
%>
How I can display the picture? (Currently I am getting com.mysql.jdbc.Blob@2e5f6a64 in display)