How to Import a Image from Database

0

I need ti import a blob image from Oracle to ireport..
hw can i do this...

I've done following changes in XML code..
But im getting errors..

<imageExpression class="java.awt.Image"><![CDATA[JRImageLoader.loadImage((byte[])$F{IMAGE})]]></imageExpression>

<field name="IMAGE" class="java.lang.Object"/>

<import value="net.sf.jasperreports.engine.util.JRImageLoader" />

Im getting this error


 

Code:
Error filling print... Error evaluating expression :      Source text : $F{IMAGE} 
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :      Source text : $F{IMAGE}      at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:195)      at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:589)      at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:557)      at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:929) </td></tr></tbody></table><br><br>Post Edited by atharindhi at 09/23/2010 13:29
atharindhi's picture
Joined: Jul 20 2010 - 8:27pm
Last seen: 4 years 1 week ago

2 Answers:

0
try using the the sql Blob's getBytes(long pos, int length) method to get the byte[]
rmukkamalla's picture
Joined: Oct 23 2008 - 1:56pm
Last seen: 5 years 9 months ago
0

Hi,

 

If you want to load the image yourself, then you can declare the field as beeing of type java.io.InputStream or java.sql.Blob.

But I suggest you simply declare the report field as being of type java.awt.Image and let JR load it for you.

 

You then make sure that the image element expression is also of type java.awt.Image.

 

I hope this helps.
Teodor

 

teodord's picture
2845
Joined: Jun 30 2006 - 9:00am
Last seen: 2 months 3 days ago
Feedback
randomness