Jump to content
We've recently updated our Privacy Statement, available here ×

pass rowcount from jrxml query to java.


sebastianr

Recommended Posts

Hi,

 

I am in need to getting total no of rows generated in jrxml from java program where my jasper execution is. But i dont want to execute a report query from java instead the query is there in the jrxml.

 

I need to get a count of records from the query executed in jrxml template.

 

Is there any way of achieving this?

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Thanks Lucian.

 

I have one more query for you which is related to perfomance.

 

In my application, i'm using Apache's Velocity with Jasper to generate the template dynamically. And i'm passing the generated pdf data as byte stream to browser directly to write.

 

In this case, what will be the performance when the concurrent users increase or report data volume is high or both.

 

I'm really worrying about the performance since the template generation, compilation, report generation and writing report to browser window are online process(Once user is made the report request).

 

Can you suggest me anything can be done to gain the good performance? Some times i am getting "OutOfMemoryException" when the report volume is so high (it cannot write the data in memory).

 

 

To avoid such situation, i would like to have a pre-defined report bandwidth and will not allow the user to generate the report if the volume exceeds the bandwidth defined. Is this acceptable? My users are ok with that.

 

Kindly share your expertise with me and suggest me the optimal way of approaching this problem.

 

Thanks.

 

 

 

:evil:

Link to comment
Share on other sites

Hi Lucian,

 

I am getting below exception when i tried this. (Jasper design is not allowing to add reportElement in summary section)

 

<parameter name="returnMap" isForPrompting="false"/>

<summary>

<staticText>

<reportElement>

<printWhenExpression>$P{returnMap}.put("var", $V{REPORT_COUNT}) == null ? Boolean.FALSE : Boolean.FALSE</printWhenExpression>

</reportElement>

</staticText>

</summary>

 

 

Exception:

 

 

Caused by: java.lang.NoSuchMethodException: No such accessible method: addElement() on object: net.sf.jasperreports.engine.design.JasperDesign

 

at org.apache.commons.digester.Digester.createSAXException(Digester.java:3181)

 

at org.apache.commons.digester.Digester.createSAXException(Digester.java:3207)

 

at org.apache.commons.digester.Digester.endElement(Digester.java:1225)

 

at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)

 

at org.apache.xerces.impl.dtd.XMLDTDValidator.endNamespaceScope(Unknown Source)

 

at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)

 

at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)

 

at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)

 

at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)

Link to comment
Share on other sites

sebastianr wrote:

I have one more query for you which is related to perfomance.

 

Posting as a new thread would have been a better idea since now people will not understand what this thread is about.

 

In this case, what will be the performance when the concurrent users increase or report data volume is high or both.

 

I'm afraid I can't predict what the performance will be. You'll have to perform some tests to find out.

 

Can you suggest me anything can be done to gain the good performance? Some times i am getting "OutOfMemoryException" when the report volume is so high (it cannot write the data in memory).

 

If your scenario permits it, I suggest caching compiled reports so that you don't have to generate and compile reports at every request.

 

To avoid such situation, i would like to have a pre-defined report bandwidth and will not allow the user to generate the report if the volume exceeds the bandwidth defined. Is this acceptable? My users are ok with that.

 

If your users find it acceptable, I have nothing against it.

 

Regards,

Lucian

Link to comment
Share on other sites

sebastianr wrote:

<summary>
<staticText>
<reportElement>
<printWhenExpression>$P{returnMap}.put("var", $V{REPORT_COUNT}) == null ? Boolean.FALSE : Boolean.FALSE</printWhenExpression>
</reportElement>
</staticText>
</summary>

 

This is not a valid JRXML fragment. The <subreport> element needs to include a <band> element, and <reportElement> has 4 required attributes.

 

You can check the JRXML reference here.

 

HTH,

Lucian

Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...