Swapneel Killekar
Swapneel Killekar

Reputation: 23

Approch for JasperReports

I am new to JasperReports, I need a few heads up before going forward with my development. My colleagues told me they are able to generate a basic report, but they are stuck with what approach should be used.

I was told we could:

  1. write the queries in each report
  2. run the queries outside the report, and pass it to the report as a datasource

Which approach is preferable? Does passing the datasource have any performance hits compared to passing the bean? Also would like to know does first approach run in a different jvm?

Current Project Architecture Struts 2 - Spring 2.5 - Spring JDBC

Upvotes: 2

Views: 373

Answers (1)

Jacob Schoen
Jacob Schoen

Reputation: 14192

If you and your team are just starting out with JasperReports I would recommend embedding the SQL query into each report. It makes building the reports in iReport much easier, since you can constantly preview your report with live data while working on it.

As far as performance, I do not think it really is not going to matter in the most basic of examples. If it is just a SQL query then no matter what scenario you use it is going to be using JDBC with the connection you give it. So I would ignore performance for now.

With that said, if you already have the data (i.e you have displayed on a screen and you want to allow the users to then export it to PDF or whatever), you could simply pass it in as a datasource and not take the performance hit of running the query again.

Another scenario you may want to use your own datasource is if you wanted to manipulate the data before it was exported in the report. Maybe some crazy sort that you could not pull off in SQL or something.

As far as your last question, it should all run in the same JVM (at least from my understanding).

Upvotes: 2

Related Questions