mortoza Posted October 28, 2006 Share Posted October 28, 2006 HelloI want my company logo to be retrieved from databse (BLOB) and displayed in the report. When I want to display, I do not see any datatype like Blob or Object. As a result getting error message telling Blob datatype can not be mapped with .... Can anyone help guiding me to the right direction in order to get the image from database and show in the jasperreport using iReport? Regards,MortozaPost edited by: mortoza, at: 2006/10/28 11:00 Link to comment Share on other sites More sharing options...
tlavalle Posted October 31, 2006 Share Posted October 31, 2006 what database are you using, I have done it with oracle, mysql. Link to comment Share on other sites More sharing options...
mortoza Posted November 5, 2006 Author Share Posted November 5, 2006 Hi TlavalleI am using mySQL database. Can you help me?Regards,Mortoza Link to comment Share on other sites More sharing options...
greenday_ra Posted November 5, 2006 Share Posted November 5, 2006 i have a same problem too. :( do you find any answer? :whistle: Link to comment Share on other sites More sharing options...
midrag Posted November 6, 2006 Share Posted November 6, 2006 Hi, try declaring the field as object. Code:<field name="logo" class="java.lang.Object"/> and cast it to byte[]Code:[code]<imageExpression class="java.awt.Image"><![CDATA[JRImageLoader.loadImage((byte[])$F{logo})]]></imageExpression> dont forget to import JRImageLoader Code:[code]<import value="net.sf.jasperreports.engine.util.JRImageLoader" /> regards, midrag Link to comment Share on other sites More sharing options...
mortoza Posted November 7, 2006 Author Share Posted November 7, 2006 Hi MidragCan you tel me how do I do this using iReport? I am not habituated in using the codes! Thanks in advance for the help.Mortoza Link to comment Share on other sites More sharing options...
mortoza Posted November 7, 2006 Author Share Posted November 7, 2006 Hi MidragI tried using iReport, its copiles well but when I run, get the following errors- ÂFilling report... ÂLocale: English (United States) ÂTime zone: defaultErrorÂfillingÂprint... java.lang.ClassCastException:Â[bÂcannotÂbeÂcastÂtoÂjava.awt.Image ÂÂÂÂatÂTest_1162930011531_354843.evaluate(Test_1162930011531_354843:163) Can you help where is the problem?Mortoza Link to comment Share on other sites More sharing options...
lucianc Posted November 7, 2006 Share Posted November 7, 2006 Try to declare your field as java.awt.Image and the JDBC data source will attempt to create an image out of the Blob data. HTH,Lucian Link to comment Share on other sites More sharing options...
midrag Posted November 7, 2006 Share Posted November 7, 2006 mortoza wrote:Hi MidragI tried using iReport, its copiles well but when I run, get the following errors-ÂFilling report... ÂLocale: English (United States) ÂTime zone: defaultErrorÂfillingÂprint... java.lang.ClassCastException:Â[bÂcannotÂbeÂcastÂtoÂjava.awt.Image ÂÂÂÂatÂTest_1162930011531_354843.evaluate(Test_1162930011531_354843:163)ÂCan you help where is the problem?Mortoza Plz post your jrxml (specially the part where using the image) Link to comment Share on other sites More sharing options...
mortoza Posted November 8, 2006 Author Share Posted November 8, 2006 HiI am attaching my .jrxml file for reference. Thanks in advance for the help.Regards,Mortoza [file name=Test.jrxml size=5705]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/Test.jrxml[/file] Link to comment Share on other sites More sharing options...
roetpag Posted November 8, 2006 Share Posted November 8, 2006 I have had some success using an url from my database (MS SQL). Basically, I insert the image into the report and in the Image Expression box I put: "http://directory/subdirectory/image_file_name.jpg" You have to include the expression in "" or you will get an error message. So if you can directly reference the path to your logo this might work for you. The Image Expression Class should be:java.lang.String I was trying to use this technique for getting student pics to appear on various reports. I had some success but I encountered errors when the student didn't have a pic in the database. Since you are trying to bring in only one pic this might work. I am sorry if this isn't the solution to your problem. I am pretty amateur at this. You might say that I am one of the monkeys at the typewriter hoping to write Shakespeare. Link to comment Share on other sites More sharing options...
midrag Posted November 8, 2006 Share Posted November 8, 2006 @mortoza: try replacingCode:<imageExpression class="java.awt.Image"><![CDATA[ $F{CompLogo}]]></imageExpression> with Code:[code]<imageExpression class="java.awt.Image"><![CDATA[JRImageLoader.loadImage((byte[])$F{CompLogo})]]></imageExpression> and dont forget to import the JRImageLoaderCode:[code]<import value="net.sf.jasperreports.engine.util.JRImageLoader" /> you can modify the jrxml from iReport by clicking Edit -> XML Source Link to comment Share on other sites More sharing options...
mortoza Posted November 8, 2006 Author Share Posted November 8, 2006 HiCan I edit this in iReport instead of writing in the xml file directly? If yes, how? Regards,Mortoza Link to comment Share on other sites More sharing options...
midrag Posted November 8, 2006 Share Posted November 8, 2006 double click on image -> image -> image expression enter: JRImageLoader.loadImage((byte[])$F{CompLogo}) importing JRImageLoader: edit -> report Import directives -> add -> net.sf.jasperreports.engine.util.JRImageLoader Link to comment Share on other sites More sharing options...
mortoza Posted November 9, 2006 Author Share Posted November 9, 2006 Hi Midrag,Brilliant! It works. Thank you very very much.Mortoza Link to comment Share on other sites More sharing options...
manishg440 Posted April 26, 2012 Share Posted April 26, 2012 hello, here i want display image from database on jasper,for that i am using but image is not coming on complilation of jasper,so please guide for this, Code:<imageExpression><![CDATA[JRImageLoader.loadImage((byte[])$F{membersdetails_AuthorizedRepSignature})]]></imageExpression> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now