How to display CLOB (or BLOB) String in iReport?

主宰稳场 提交于 2019-12-22 10:46:49

问题


I need to display a CLOB field with longer than 4000 characters in a text field using in iReport. I am using iReport version 5.5.0, I tried converting the CLOB to InputStream but it did not work, all I get is:

java.io.ByteArrayInputStream@43842a66

I tried getSubString(long,int) but it only works for strings smaller than 4000 chars. stringValue() and toString() also did not work.

Thanks for any help.

EDIT:

Clob.getSubString(long,int) method worked fine in my latter tests, I don't know why it didn't work before. So I used:

$F{FIELD}.getSubString( (long)1, (int)$F{FIELD}.length() )

eventually. It may not be the best option, but I figured max length of a String (2147483647) is more than enough for the field.


回答1:


I had the same problem, and i found the following solutions.

First

one is placing the following statement in the Textfield expression. catch to this is the field should be free of carriage returns and line feeds to show the complete field value. I populate the field through sql query.

new BufferedReader(new InputStreamReader($F{FIELD_NAME})).readLine()

Second

creating a method in a class where in the InputStream is converted to ByteArrayOutputStream and converting it to String and then calling this method in the Textfield expression with CLOB value passed in.

In both cases the field should be declared as java.io.InputStream.

For more details.



来源:https://stackoverflow.com/questions/22762910/how-to-display-clob-or-blob-string-in-ireport

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!