我正在尝试使用image-field在Pentaho Reports Designer中显示Derby数据库的BLOB字段中的人物的PNG图像。但是,图像没有显示。我也创建了以下BSH功能,但没有奏效。我做错了什么。请帮忙。
Object getValue()
{
var blobObject = dataRow.get("IMAGE");
long blobLength = blobObject.length();
byte[] blobContent = blobObject.getBytes((long)1, (int)blobLength);
return Toolkit.getDefaultToolkit().createImage(blobContent);
}
我收到日志中的警告信息
2014-03-15 07:53:09,897 [45929284] WARN - org.pentaho.reporting.engine.classic.core.modules.misc.beanshell.BSHExpression - Evaluation error: class bsh.TargetError - Sourced file: inline evaluation of: ``getValue ();'' : Method Invocation blobObject.getBinaryStream
Sourced file: inline evaluation of: ``getValue ();'' : Method Invocation blobObject.getBinaryStream : at Line: 7 : in file: inline evaluation of: ``java.awt.Image getValue() { var blobObject = dataRow.get("IMAGE"); //long bl . . . '' : blobObject .getBinaryStream ( )
Called from method: getValue : at Line: 1 : in file: inline evaluation of: ``getValue ();'' : getValue ( )
Target exception: java.sql.SQLException: You cannot invoke other java.sql.Clob/java.sql.Blob methods after calling the free() method or after the Blob/Clob's transaction has been committed or rolled back.
at bsh.BSHMethodInvocation.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHArguments.getArguments(Unknown Source)
at bsh.BSHMethodInvocation.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHReturnStatement.eval(Unknown Source)
at bsh.BSHBlock.evalBlock(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BshMethod.invokeImpl(Unknown Source)
at bsh.BshMethod.invoke(Unknown Source)
at bsh.BshMethod.invoke(Unknown Source)
at bsh.Name.invokeLocalMethod(Unknown Source)
at bsh.Name.invokeMethod(Unknown Source)
at bsh.BSHMethodInvocation.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at org.pentaho.reporting.engine.classic.core.modules.misc.beanshell.BSHExpression.getValue(BSHExpression.java:185)
at org.pentaho.reporting.engine.classic.core.states.datarow.ExpressionEventHelper.evaluateSingleExpression(ExpressionEventHelper.java:822)
at org.pentaho.reporting.engine.classic.core.states.datarow.ExpressionEventHelper.reactivateExpressions(ExpressionEventHelper.java:807)
at org.pentaho.reporting.engine.classic.core.states.datarow.ExpressionDataRow.fireReportEvent(ExpressionDataRow.java:435)
at org.pentaho.reporting.engine.classic.core.states.datarow.GlobalMasterRow.fireReportEvent(GlobalMasterRow.java:380)
at org.pentaho.reporting.engine.classic.core.states.datarow.DefaultFlowController.fireReportEvent(DefaultFlowController.java:447)
at org.pentaho.reporting.engine.classic.core.states.process.ProcessState.fireReportEvent(ProcessState.java:1284)
at org.pentaho.reporting.engine.classic.core.states.process.BeginDetailsHandler.advance(BeginDetailsHandler.java:51)
at org.pentaho.reporting.engine.classic.core.states.process.ProcessState.advance(ProcessState.java:1076)
at org.pentaho.reporting.engine.classic.core.layout.output.AbstractReportProcessor.processPaginationLevel(AbstractReportProcessor.java:730)
at org.pentaho.reporting.engine.classic.core.layout.output.AbstractReportProcessor.prepareReportProcessing(AbstractReportProcessor.java:534)
at org.pentaho.reporting.engine.classic.core.modules.output.pageable.graphics.PrintReportProcessor.getNumberOfPages(PrintReportProcessor.java:78)
at org.pentaho.reporting.engine.classic.core.modules.gui.base.PreviewPane$RepaginationRunnable.run(PreviewPane.java:271)
at org.pentaho.reporting.engine.classic.core.util.Worker.run(Worker.java:174)