I am using ireport tool in my application. There is a requirement to show the image on report. I have a blob object field in the database to store image. I need to show the blob object field as an image in the report.
However, it working fine if I retrieve any other data except Blob
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4_2" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="6bf1e8fc-5bd2-495a-abca-8c4d501c73af">
<queryString><![CDATA[SELECT image FROM myimage]]></queryString>
<field name="image" class="java.io.InputStream"/>
<detail>
<band height="125" splitType="Stretch">
<image>
<reportElement x="130" y="20" width="310" height="88" uuid="8b07de5d-ac9e-4245-9ca1-ccd6fd3fe993"/>
<imageExpression><![CDATA[$F{image}]]></imageExpression>
</image>
</band>
</detail>
</jasperReport>
I'm getting this error:
"net.sf.jasperreports.engine.JRException: Unable to get value for result set field "image" of class java.io.InputStream"
Have any idea?
Agreed with @joyo. I followed his example and it worked. Here is a complete example of what he meant (just in case anyone is interested):
I found the solution. Steps to fix issue:
<field name="image" class="java.io.InputStream"/>