Hello
I 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,
Mortoza
Post edited by: mortoza, at: 2006/10/28 11:00
I 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,
Mortoza
Post edited by: mortoza, at: 2006/10/28 11:00
15 Answers:
Posted on November 6, 2006 at 7:03am
Hi,
try declaring the field as object.
try declaring the field as object.
Code: |
<field name="logo" class="java.lang.Object"/></td></tr></tbody></table><br /> <br /> and cast it to byte[]<br /> <table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre><imageExpression class="java.awt.Image"><![CDATA[JRImageLoader.loadImage((byte[])$F{logo})]]></imageExpression></td></tr></tbody></table><br /> <br /> dont forget to import JRImageLoader<br /> <br /> <table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre><import value="net.sf.jasperreports.engine.util.JRImageLoader" /></td></tr></tbody></table><br /> <br /> regards,<br /> <br /> midrag |
Posted on November 7, 2006 at 5:08am
Hi Midrag
I tried using iReport, its copiles well but when I run, get the following errors-
ÂFilling report...
ÂLocale: English (United States)
ÂTime zone: default
ErrorÂ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
I tried using iReport, its copiles well but when I run, get the following errors-
ÂFilling report...
ÂLocale: English (United States)
ÂTime zone: default
ErrorÂ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
Posted on November 7, 2006 at 8:10am
mortoza wrote:
Plz post your jrxml (specially the part where using the image)
Hi Midrag I tried using iReport, its copiles well but when I run, get the following errors- ÂFilling report... ÂLocale: English (United States) ÂTime zone: default ErrorÂ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)
Posted on November 8, 2006 at 1:30pm
Hi
I 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/Tes...
I 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/Tes...
Posted on November 8, 2006 at 1:47pm
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:
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.
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.
Posted on November 8, 2006 at 2:06pm
@mortoza:
try replacing
try replacing
Code: |
<imageExpression class="java.awt.Image"><![CDATA[ $F{CompLogo}]]></imageExpression></td></tr></tbody></table><br /> <br /> with<br /> <br /> <table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre><imageExpression class="java.awt.Image"><![CDATA[JRImageLoader.loadImage((byte[])$F{CompLogo})]]></imageExpression></td></tr></tbody></table><br /> <br /> and dont forget to import the JRImageLoader<br /> <table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"><tbody><tr><td><b>Code:</b></td></tr><tr><td><pre><import value="net.sf.jasperreports.engine.util.JRImageLoader" /></td></tr></tbody></table><br /> <br /> you can modify the jrxml from iReport by clicking Edit -> XML Source |
Posted on April 25, 2012 at 8:15pm
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></td></tr></tbody></table> |