如何使用sqlite数据库中的JasperReports显示Blob对象图像? [英] How to show blob object image using JasperReports from sqlite database?

查看:61
本文介绍了如何使用sqlite数据库中的JasperReports显示Blob对象图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中使用ireport工具.需要在报告上显示图像.我在数据库中有一个Blob对象字段,用于存储图像.我需要在报告中将blob对象字段显示为图像.

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.

但是,如果我检索到除Blob之外的任何其他数据,它就可以正常工作

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>

我收到此错误: "net.sf.jasperreports.engine.JRException: Unable to get value for result set field "image" of class java.io.InputStream"

有什么想法吗?

推荐答案

我找到了解决方案.解决问题的步骤:

I found the solution. Steps to fix issue:

  1. 将属性类型从Blob更改为Binary
  2. 更改字段的类型:<field name="image" class="java.io.InputStream"/>

这篇关于如何使用sqlite数据库中的JasperReports显示Blob对象图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆