如何使用JasperReports查看Oracle中blob列的图像? [英] How to view an image from blob column in Oracle with JasperReports?

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

问题描述

我尝试在报表布局中定义一个图像元素,并将类型设置为java.io.Inputstream,但这不起作用,我也尝试设置为java.awt.Image并且都不起作用,我得到的例外情况是

I tried defining an image element in the report layout and setting type to java.io.Inputstream but that doesn't work, also I tried setting to java.awt.Image and neither works, the exception that I'm getting is

java.lang.ClassCastException: oracle.sql.BLOB cannot be cast to java.awt.Image

java.lang.ClassCastException: oracle.sql.BLOB cannot be cast to java.io.InputStream

另外我也是尝试谷歌,但结果是我现在正在做的。

Also I tried to google but the results are that what I'm doing right now.

感谢您的帮助。

推荐答案

没有看到你如何调用blob将图像嵌入到报告代码中...

Without seeing how you're calling the blob to embed the image within your report code...


  1. 使用 blob.getBinaryStream()

  2. 使用 javax.imageio.ImageIO.read(InputStream)

  1. Use blob.getBinaryStream().
  2. Convert the stream using javax.imageio.ImageIO.read( InputStream ).

例如:

javax.imageio.ImageIO.read( blob.getBinaryStream() )

这将返回 BufferedImage ,其子类为 java.awt.Image ,应该是嵌入报告的合适对象。

This will return an instance of BufferedImage, which subclasses java.awt.Image, and should be a suitable object to embed in the report.

显示的 blob 变量该示例必须使用报表中的相应变量(表示所需列中的数据)。

The blob variable shown in the example will have to use the appropriate variable from the report (that represents the data from the desired column).

另请参阅:

  • https://forums.oracle.com/forums/thread.jspa?threadID=2081381

这篇关于如何使用JasperReports查看Oracle中blob列的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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