JasperReports 在生成报告之前是否读取列元数据?
我制作了一些 JasperReports,并且在 Windows 机器上运行得很好。当报告被设置为在具有 zOS 操作系统的大型机上运行时,问题就出现了。
问题是:当 Jasper 创建报告时,它似乎从数据库中读取表元数据,并基于它期望数据出现。
示例:如果我有一个 varchar(20) 类型的列,那么即使报告字段定义为字符串,Jasper 也只会等待 20 个字符。
在 Windows 环境中不会发生这种情况,但在大型机上,字符编码是 EBCDIC,因此该列在大型机上可能有 19 个字符,但在编码时,它会以 23 或 24 个字符返回到报告。
注意:此问题仅出现在非英文字符中。
更新
当 Jasper 创建报告时,会引发 ConversionBufferFull
,因为我无法访问大型机日志,所以我没有完整的跟踪。仅当名为 COUNTRY_DESC 的一列的值约为 17-20 个字符时,就会出现该问题,并且会发生异常。
正如我提到的,大型机上的字符集是 EBCDIC,但是当它通过 JDBC 读取时,它会转换为 Unicode。例如,在 EBCDIC 中,该单词将是 17 个字符,但转换后它会变成 22 个。出于某种奇怪的原因,Jasper 只期望该字段为 20 个字符。
I have a few JasperReports made and running very fine on a Windows machine. The problem started when the reports were set to run on a mainframe with zOS operating system.
The problem is: when Jasper creates the report it seems to read the tables metadata from the database and based on it expect the data to come.
Example: if i have a column of type varchar(20), then Jasper will be waiting for 20 chars only even if the report field is defined as String.
That doesn't happen in Windows environment, but on the mainframe the character-encoding is EBCDIC, and so the column might have 19 chars on the mainframe, but when encoded its returned to the report as 23 or 24 characters.
Note: this problem only occurs in non-English characters.
UPDATE
A ConversionBufferFull
is thrown when Jasper is creating the report, i don't have the full trace since i can't access the mainframe log. The problem occurs with only one column called COUNTRY_DESC when the value is around 17-20 chars, the exception occurs.
As i mentioned the character set on the mainframe is EBCDIC, but when its read through the JDBC its converted to Unicode. for example in EBCDIC the word will be 17 chars, but when converted it become 22. For some strange reason Jasper expects 20 for this field only.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
JasperReports 本身不管理数据转换,也不管理字段长度。这看起来像是 JDBC 驱动程序的问题。
谢尔曼
贾斯珀软件公司
JasperReports itself does not manage the data conversion, nor the field length. This looks like an issue with the JDBC driver.
Sherman
Jaspersoft
sun.io.ConversionBufferFullException
由sun.io
字符编码转换器抛出,并且可能通过旧版本 Java 中的java.io
类冒泡。此 API 已被弃用一段时间,并且自 Java 6 -java.nio.charset
被使用以来不再使用。这是 JasperReports、您的 JDBC 驱动程序或这两者使用的东西中的字符转换错误。我认为这与从 JDBC ResultSet 本身读取元数据没有任何关系,尽管元数据中的字符串可能被错误转换。
如果没有堆栈跟踪,很难归咎于问题或想出解决方法。
sun.io.ConversionBufferFullException
is thrown bysun.io
character encoding converters and may bubble up throughjava.io
classes in older versions of Java. This API has been deprecated for some time and is no longer in use since Java 6 -java.nio.charset
is used instead.It is a character conversion bug in either JasperReports, your JDBC driver or things used by those two. I don't think it has anything to do with reading meta-data from the JDBC ResultSet per se, although it might be the strings in the meta-data that is incorrectly converted.
It's hard to place the blame or think up a work-around without the stack trace.