2006 IR Open Discussion Posted August 18, 2006 Share Posted August 18, 2006 By: Navaneetha Krishnan J - navaneethanj Tips to invoke jasper reports faster. 2003-04-10 08:31 Hi, 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; try { String compileFileName = designFileName + ".jasper"; Class.forName("org.gjt.mm.mysql.Driver"); conn = DriverManager.getConnection("jdbc:mysql://localhost/MyDB","",""); if(query == null || query.trim().equals("")) { print = dori.jasper.engine.JasperFillManager.fillReport(compileFileName, null, conn); } else { 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 Navaneethan By: Teodor Danciu - teodord RE: Tips to invoke jasper reports faster. 2003-04-10 09:18 Hi, Question: Why are you compiling the XML design every time? Does your report template change with every execution? 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. Teodor Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now