0

HOW TO DISPLAY IMAGES FROM MYSQL USING HIBERNATE

asked 2008-09-21 11:30:28 +0800

rodopsko gravatar image rodopsko
21 2

Hİ, I'am storing my images in mysql using hibernate without any problems. My MemberImages Table structure(id,filename,data,members_id).
The question is , how to display images using hibernate?

delete flag offensive retag edit

4 Replies

Sort by » oldest newest

answered 2008-09-21 15:01:21 +0800

dennis gravatar image dennis
3669 1 6
http://www.javaworld.com....

Please read the javadoc about AImage and Image.setContent

link publish delete flag offensive edit

answered 2008-09-21 15:20:55 +0800

rodopsko gravatar image rodopsko
21 2

I mean get image from mysql database using hibernate and display it.
I save image with code below , but I can not get it and display !!!

fi = ((Media) media).getByteData();
((Image)getFellowIfAny("img")).setContent((org.zkoss.image.Image) media);


memberImage = new MemberImages();
memberImage.setName(name);
memberImage.setData(fi);
memberImage.setMembers_id(this.curr_member_id);

manager_memberImage.insert(memberImage);

link publish delete flag offensive edit

answered 2008-09-22 00:55:27 +0800

dennis gravatar image dennis
3669 1 6
http://www.javaworld.com....

Where the media come from? what is the mine type of this media? any code can show that?

link publish delete flag offensive edit

answered 2008-09-23 13:06:20 +0800

ansancle gravatar image ansancle
317 9

Get the image data from the db and use the byte[] :

public createZKImagesFromByteArray(String imageName,byte[] imageData)
{
    AImage  alImage  = new AImage(imageName,imageData);	
    org.zkoss.zul.Image zkImage = new org.zkoss.zul.Image();
    zkImage.setContent(alImage);
    		
    org.zkoss.image.Image newImageFromDB = zkImage.getContent();
}

You can see here how to get both a org.zkoss.image.Image and a org.zkoss.zul.Image from byte[].
Once you have the image in the zk iimage classes you should be all set.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2008-09-21 11:30:28 +0800

Seen: 1,081 times

Last updated: Sep 23 '08

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More