Jump to content

Tips to invoke jasper reports faster.

Recommended Posts

By: Navaneetha Krishnan J - navaneethanj

Tips to invoke jasper reports faster.

2003-04-10 08:31



I am using following code to generate the JasperPrint object. This code taking 10 secs to execute. Is there a better way to do the same?

Thanks for your help in advance.


String designFileName = rip.getDesignFileName(reportName);

String query = rip.getQuery(reportName);

JRDataSource jrds = null;

Statement stmt = null;

ResultSet rs = null;

Connection conn = null;

dori.jasper.engine.JasperPrint print = null;



String compileFileName = designFileName + ".jasper";


conn = DriverManager.getConnection("jdbc:mysql://localhost/MyDB","","");

if(query == null || query.trim().equals(""))


print = dori.jasper.engine.JasperFillManager.fillReport(compileFileName, null, conn);




stmt = conn.createStatement();

rs = stmt.executeQuery(query);

jrds= new JRResultSetDataSource(rs);


JasperCompileManager.compileReportToFile(designFileName, compileFileName);

print = dori.jasper.engine.JasperFillManager.fillReport(compileFileName, null, jrds);

return print;



Thanks & Regards






By: Teodor Danciu - teodord

RE: Tips to invoke jasper reports faster.

2003-04-10 09:18





Why are you compiling the XML design every time?

Does your report template change with every


If not, you can produce the .jasper file at design

time, just like you compile your usual .class files

and then use it over and over again.


The report compilation process is time consuming

and should be avoided. Even if you need to let your

users the possibility to define their own report

templates, or alter them before filling with data,

you should provide them with a way to define those

templates and store them in .jasper format for

later use. This way you can avoid compiling them

every time as I'm sure the users will prefer to reuse

already defined templates instead of redefining them

over and over again.


I hope this helps.


Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...