-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Retrieve/Show image (blob) on JSP
PostPosted: Mon Jan 21, 2008 5:18 pm 
Newbie

Joined: Mon Jan 21, 2008 4:59 pm
Posts: 10
Location: Ecuador
Hello.

I'm a begginer with Java and Hibernate. Have an important project for college. I hope somebody can help me. Thank you.
Hibernate version:3.2
Mapping document:
<property name="Image" column="IMAGE" type="binary" not-null="false" /> </property>
Code between sessionFactory.openSession() and session.close():

Session session = sessionFactory.getCurrentSession();
Blob result = null;
try {
session.beginTransaction();
Blob blob = (Blob) session.createSQLQuery("SELECT image as image FROM Imgsartic").addScalar("image").uniqueResult();
result = blob;
session.getTransaction().commit();
}
catch (Exception e) {
e.printStackTrace();
} return result;
Name and version of the database you are using:
Oracle Express 10g
JSP CODE:
<%
session.setAttribute( "ImgsArtic", revista.DAO.getImagen());
%>
<c:out value="${ImgsArtic}" />


Running the app shows next text:
org.hibernate.lob.SerializableBlob@135f92f

It seems corresponds to the "serial blob locator" I have reading these days from some people on forum.

I'm success working with clobs, but now with images and blobs I'm broken. The table has only 1 record. I don't know how to get and show the image on my jsp page.

Thank you very much for your time.
BM


Top
 Profile  
 
 Post subject: Re: Retrieve/Show image (blob) on JSP
PostPosted: Fri Jan 25, 2008 4:59 am 
Newbie

Joined: Thu Jan 24, 2008 1:24 am
Posts: 3
use same name for your "propery" and "column" like image for both and
use "binary" for result variable like binary result.If you having blob data type in your Database then user mediumblob instead of blob because blob can store 64kb while mediumblob can store 16mb.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 28, 2008 1:21 pm 
Newbie

Joined: Mon Jan 21, 2008 4:59 pm
Posts: 10
Location: Ecuador
Thanks for the answer.

I used byte[] and doesn't work. Can't find nothing for "binary".


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.