我有带BLOB列的sqlite db包含图像。我一直在寻找很多没有运气的解决方案。
我将图像字段(列)设置为java.io.InputStream
的类,但是我得到了错误提示"jasperreports.engine.JRException: Unable to get value for result set field "image" of class java.io.InputStream"
我在@joyo的下面找到了这种解决方案。他说先将BLOB转换为二进制。无论如何,我找不到这样做。我认为这是一个更多的SQL的东西。
How to show blob object image using JasperReports from sqlite database?
我应该怎么做才能将BLOB转换为Binary或任何其他解决方法,以便在jaspersoft中动态显示图像?
我试图将字段类设置为BLOB或InputStream,这使我即使不使用也无法加载字段。
ByteInputStream允许渲染文件,但是在这种情况下我不知道如何处理图像表达?
我的代码看起来像
<?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_3" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<queryString language="SQL">
<![CDATA[SELECT PicT1 FROM HTNlist]]>
</queryString>
<field name="PicT1" class="java.io.InputStream"/>
<detail>
<band height="60" splitType="Stretch">
<image>
<reportElement x="252" y="10" width="50" height="50"/>
<imageExpression><![CDATA[$F{PicT1}]]></imageExpression>
</image>
</band>
</detail>
</jasperReport>
这给我错误提示
net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRException: Unable to get value for result set field "PicT1" of class java.io.InputStream.
at com.jaspersoft.studio.editor.preview.view.control.ReportController.fillReport(ReportController.java:536)
at com.jaspersoft.studio.editor.preview.view.control.ReportController.access$17(ReportController.java:511)
at com.jaspersoft.studio.editor.preview.view.control.ReportController$1.run(ReportController.java:429)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
Caused by: net.sf.jasperreports.engine.JRException: Unable to get value for result set field "PicT1" of class java.io.InputStream.
at net.sf.jasperreports.engine.JRResultSetDataSource.getFieldValue(JRResultSetDataSource.java:385)
at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:1501)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1402)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1378)
at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1194)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:108)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:615)
at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFill.run(BaseFillHandle.java:135)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.sql.SQLException: not implemented by SQLite JDBC driver
at org.sqlite.Unused.unused(Unused.java:29)
at org.sqlite.Unused.getBlob(Unused.java:96)
at net.sf.jasperreports.engine.JRResultSetDataSource.readBytes(JRResultSetDataSource.java:703)
at net.sf.jasperreports.engine.JRResultSetDataSource.getFieldValue(JRResultSetDataSource.java:251)
... 8 more