Your SlideShare is downloading. ×
Bhushan S. Sapre, Pankaj R. Ulhe, Dr. B. B. Meshram / International Journal of Engineering         Research and Applicatio...
Bhushan S. Sapre, Pankaj R. Ulhe, Dr. B. B. Meshram / International Journal of Engineering         Research and Applicatio...
Bhushan S. Sapre, Pankaj R. Ulhe, Dr. B. B. Meshram / International Journal of Engineering         Research and Applicatio...
Bhushan S. Sapre, Pankaj R. Ulhe, Dr. B. B. Meshram / International Journal of Engineering         Research and Applicatio...
Bhushan S. Sapre, Pankaj R. Ulhe, Dr. B. B. Meshram / International Journal of Engineering         Research and Applicatio...
Upcoming SlideShare
Loading in...5
×

Fh24984988

195

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
195
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Fh24984988"

  1. 1. Bhushan S. Sapre, Pankaj R. Ulhe, Dr. B. B. Meshram / International Journal of Engineering Research and Applications (IJERA) ISSN: 2248-9622 www.ijera.com Vol. 2, Issue 4, July-August 2012, pp.984-988Report Generation System Using JasperReports and SQL Stored Procedure Bhushan S. Sapre*, Pankaj R. Ulhe**, Dr. B. B. Meshram*** *(Department of Computer Technology, Veetmata Jijabai Technilogical Institute, Matunga, Mumbai) **(Technical Specialist, Mastek Ltd., Seepz, Andheri, Mumbai) ***(Head of Dept. of Computer Technology, Veermata Jijabai Technological Institute, Matunga Mumbai)ABSTRACT The contents of this paper mainly focus elements and relationships, this is useful for makingon study of the Report generation system using effective management decision[10].JasperReports, an open-source reporting tool, for The traditional generation method of reportsrealization and implementation of dynamic and is relatively curable, once the system developmentreusable reports. Stored SQL procedures are used was completed, all reports’ formats are fixed.to retrieve data from database. iReport is a GUI Therefore it is not possible to change format of reportbased report designer assists the realization of the according to changes in circumstances and cannotreports. The separation of the report template customize them of personal fashion. When content orfrom report data provided by JasperReports has format of the report changes, we need to modify theprovided ease of development and maintenance of code constantly to adapt changes which restrictsreports in overall system. This report system is progress of the project. Therefore we generally usesupported by Spring framework which provides XML documents to give the definition, using the ideaJava environment of system. This data report of the separation of report format and report data.system can be used to generate reports Format module of reports extract XML format filesdynamically and improve overall system’s from the template library of report format, datareusability and maintainability. module of reports extract relevant data from the database, finally, the report was compiled andKeywords - iReport, JasperReports, Stored displayed by reports builder[1]. However, this kind ofProcedure reports needs to develop oriented database, resulting in reliance on the data source and reducing reuse and1. INTRODUCTION portability of the reports.This paper focuses on Report is a self-explanatory statement of JasperReports, an open source reorting tool alongfacts relating to a specific subject and serves the with a GUI based report designer, iReport. It ispurpose of providing information for decision combined with Hibernate to create dynamic andmaking and follow up actions. Report is an important reusable report generation system.In project whichtool in project management, and its purpose is to help based on open-source framework of SpringMVC, wemanagers quickly grasp the raw data of the basic used this report system to generate reports and 984 | P a g e
  2. 2. Bhushan S. Sapre, Pankaj R. Ulhe, Dr. B. B. Meshram / International Journal of Engineering Research and Applications (IJERA) ISSN: 2248-9622 www.ijera.com Vol. 2, Issue 4, July-August 2012, pp.984-988invoices and successfully constructed a stable and library and apply it to any kind of Java applicationefficient system. process. iReport is distributed, and described by pure Java which correspondence with GNU General2. THE CHOICE, ANALYSIS AND Public License. iReport provides a relatively perfectAPPLICATION OF THE REPORT platform for visual editing of report template, using itBUILDER we just need a simple operation to design the demand interface. It can graphically edit JRXML documents2.1 Working of JasperReports and support for PDF, RTF, XML, XLS, CSV, HTML With the development of open source and many other formats, and it also can support forsoftware, especially Linux OS, open source software the realization of XML data sources. The relationshipbeing gradually accepted and respected by the between the content and performance of report ispeople, it played an increasingly important role in IT. configured by JRXML file; this can bind differentJasperReports is an open source report tool which domains and different databases, so that reports canwritten in pure Java, it can run on any Java- be applied under different datasource environment.application environment, including J2EE and other iReport also compiles JRXML file to formweb applications[10]. ‘.JASPER’ file which is used to fill data from JasperReports has a good cross platform and datasource. This method provides separation betweencompatibility. It can dynamically display reports of template of the report and data of the report i.e. reportvarious styles and formats. It also can display rich template is independent of the data displayed by thecontent of the page and convert these pages into report. It avoids complexity and is perfect for rapidXLS, RTF, PDF, HTML and XML format, showing production of the reports.its applicability. Moreover, iReport as a productiontool of front-end interface, it has made a considerable 3. USE OF STORED PROCEDURE TOimprovement by providing facility to create charts, FILL REPORTSsub-tables, meet schedules, and other more complexreports[3]. 3.1 Introduction to Stored Procedure Figure 1 describes the process of report A stored procedure is a subroutine availablegeneration by JasperReports. Report generation starts to applications that access a relational databasewith JRXML file which is also called as Report system. A stored procedure or in simple a proc is atemplate. JRXML file contains the report structure named PL/SQL block which performs one or moreinformation. JRXML file parsed by JRXmlLoader specific task. This is similar to a procedure in otherand converted into JasperDesign Object. programming languages. A procedure has a headerJasperDesign Object contains only design and a body. The header consists of the name of theinformation of the report. After compiling procedure and the parameters or variables passed toJasperDesign Object using JRCompiler it gets the procedure. The body consists or declarationconverted into Jasper Report without Data. Now Data section, execution section and exception sectionfilled into empty JasperReport Object using similar to a general PL/SQL Block. A procedure isRS(Result Set) and it will be converted into similar to an anonymous PL/SQL Block but it isJasperPrint Object. Form JasperPrint Object you have named for repeated usage.two options: JasperPrintManager from which you can Stored Routines (Procedures and Functions)print the report or view the report on the screen else are supported in version MySQL 5.0. StoredJasperExportManager from which you can export Procedure is a set of statements, which allow easereport in HTML, PDF, XLS format. and flexibility for a programmer because stored procedure is easy to execute than reissuing the2.2 iReport: Visual Report Designer Studio number of individual SQL statements. Stored procedure can call another stored procedure also. Preocess of report generation starts from Stored Procedure can very useful where multipleJRXML file. This JRXML can be written manually client applications are written in different languagesbut it is complex and time consuming. Moreover we or it can be work on different platforms but they needneed to learn how to structure JRXML file as per to perform the same database operations.syntax and semantics of JasperReports. Therefore we Store procedure can improve thechoose iReport, a front page showing and producing performance because by using the stored proceduretool that matches with JasperReports[11]. less information needs to be sent between the server It is mainly used in the visual design and and the client. It increases the load on the databasegeneration of JRXML file in statements form used by server because less work is done on the client sideJasperReports, as JasperReports itself did not provide and much work is done on the server side.a good visual statements design tools, the appearance We can pass parameters to procedures in three ways,of iReport has just make up for the deficiencies. At viz. IN-parameters, OUT-parameters and INOUT-the same time, iReport can call the JasperReports parameters 985 | P a g e
  3. 3. Bhushan S. Sapre, Pankaj R. Ulhe, Dr. B. B. Meshram / International Journal of Engineering Research and Applications (IJERA) ISSN: 2248-9622 www.ijera.com Vol. 2, Issue 4, July-August 2012, pp.984-988 The parameter list is available within the Jasper Reports is unable to call Oracleparentheses. Parameter can be declared to use any stored procedures directly, because procedures do notvalid data type, except that the COLLATE attribute return standard result sets. As a solution, in Oracle,cannot be used. By default each parameter is an IN you can use a stored function to retrieve the results ofparameter. For specifying other type of parameter a stored procedure. There are a few more steps to doused the OUT or INOUT keyword before the this than if you were able to use a stored procedure,parameter name. but it currently is the only option, if the query you An IN parameter is used to pass the value need to do can’t be done with a standard SQL query.into a procedure. The procedure can be change the In order to to use stored functions to retrieve thevalue but when the procedure return the value then result set of a stored procedure, you will need to use amodification is not visible to the caller. An OUT temp table to hold the results, and then return theparameter is used to pass the value from the results using types and tables of types. In iReportprocedure to the caller but its visible to the caller. An designer go to Tools. Under Options, go to ClasspathINOUT parameter is initialized by the caller and it Tab. Click Add JAR and add the OJDBC14.jar to thecan be modified by the procedure, and any change classpath. Go to Query Executer tab and set themade by the procedure is visible to the caller. Language as PLSQL. Select Database JDBC For each OUT or INOUT parameter you Connection. Select Oracle as the JDBC Driver ashave to pass a user defined variable because then the shown in the image below and verify the connectionprocedure returns the value then only you can obtain by clicking the Test button. Create a blank report byit values. But if you invoking the procedure from the giving a report name and save it. Open the report inother procedure then you can also pass a routine the designer and right click on the report name andparameter or variable as an IN or INOUT parameter. click on Edit Query. Call your procedure with in { } The procedure body contains the valid SQL a. {callprocedure statement that can be a simple statement PUBLISHER_AND_BOOKS(&P(P_PUBLISHER_Ilike SELECT or INSERT or they can be a compound D), &P(ORACLE_REF_CURSOR))}.statement written using BEGIN and END. Compound P_PUBLISHER_ID is of type string andstatement can consists declarations, loops or other SYS_REFCURSOR is of type java.sql.ResultSet datacontrol structure. type custom parameter. You need to import ‘java.sql.*’ in JRXML file. This has to be done byCREATE [OR REPLACE] PROCEDURE editing XML file manually. You can create this byproc_name [list of parameters] clicking the New Parameter button. If you have moreIS input parameters use ‘,’ as your delimiter as shown in Declaration section the above example. Click Ok and proceed with theBEGIN report design. In the designer window right click on Execution section Fields and add click Add Fields and make sure all theEXCEPTION field name matches the column name in your stored Exception section procedure. Now right click on the parameters and addEND; the parameters matching the stored procedure NOTE: make sure you uncheck the "Use for Prompt" in the3.2 Benefits of Stored Procedures property for your out parameter in our example its Precompiled execution. SQL Server SYS_REFCURSOR is the out parameter. Drag andcompiles each stored procedure once and then drop the fields in the report detail band.reutilizes the execution plan. This results intremendous performance boosts when stored 4. SYSTEM ARCHITECTURE AND ITSprocedures are called repeatedly. ADVANTAGESReduced client/server traffic. If network bandwidth isa concern in your environment, youll be happy to 4.1 Process of report generationlearn that stored procedures can reduce long SQL The system uses architecture of SpringMVCqueries to a single line that is transmitted over the which is an open-source framework. Functionwire. modules of system can be divided into: user Efficient reuse of code and programming management module, system management module,abstraction. Stored procedures can be used by project management module, schedule managementmultiple users and client programs. If you utilize module, query and statistics report module.them in a planned manner, youll find the SpringMVC framework is one of the best MVCdevelopment cycle takes less time. frameworks by far, it has a strong Servlet control Enhanced security controls. You can grant functions, its page navigation structure that based onusers permission to execute a stored procedure xwork.xml configuration files is very clear, responseindependently of underlying table permissions. speed of its jump control function is also very fast. And SpringMVC has a flexible view of expression3.3 Using Stored Procedure with JasperReports 986 | P a g e
  4. 4. Bhushan S. Sapre, Pankaj R. Ulhe, Dr. B. B. Meshram / International Journal of Engineering Research and Applications (IJERA) ISSN: 2248-9622 www.ijera.com Vol. 2, Issue 4, July-August 2012, pp.984-988and can support for report output of JasperReports, so type which is object-oriented, then return to thethat it can greatly simplify and speed up report JasperReports to generate report view engine.development[8]. Module 2 provides report templates in the form of System accesses data through SpringMVC .JRXML file generated through iReport toand Hibernate, besides SprongMVC will monitor the JasperReports Engine.request of Spring affairs. Business layer usesconstruction function of Spring, we use it to managethe data source and the establishment and recovery of 4.2 Advantagesdatabase connection pool. Data persistent layerintegrates Hibemate in the SpringMVC framework. From figure 2 we can see that JasperReportsThis has realized a changement from a relational in the SpringMVC framework has two modules toquery to an object-oriented query, and Hibernate generate a report: module 2 and module 3. If welargely optimize a query process. Chart of system want to develop different reports, only have toframework and process of JasperReports generating package the data in the module 2 into differentreport shown in Figure 2. JavaBean data model, such a development process Figure 2 is divided into module 1,2 and 3. well reflects parallel design pattern of the MVC, itModule 1 has responsibility to accept request from can greatly improve the development efficiency ofclient and pass it to module 2. Module 1 basically report. Module 3 realizes style design of reports byforms Controller part of the MVC framework. Web iReport, thats easy to design reports according toapplication accepts HTTP requests from client passes business needs, then enabling the division andit to the Spring framework. Spring framework has a parallel development of the data and view[10].controller implementation for each type of request. Data query module is extremely importantBy analyzing the request and parameters packed with module in this system. Data retrieving is done by thisthe request, an appropriate call is made to the module. Data retrieval is done using SQL storedJasperReports Engine. JasperReports Engine is procedure. Problem with JRXML file is that it needsprovided with DAO and path of .JRXML file. to be compiled whenever any modifications are madeCompilation of the .JRXML file is responsibility of to file. It is applicable even when query written toJasperReports Engine. JasperReports Engine makes access data is changed. Therefore if query keepscall to database through DAO. Module 2 achieves changing, we need to compile file the JRXML file asdata access and model package: integrate the many times the query changes. On the other hand, ifHibernate which is the open source O/R relational we use stored procedure, we just need to make a callmapping tools and bases on Spring framework, from JRXML file and collect the records in Resultpackage the relationship data that obtained by JDBC set. On the database side we change the logic inconnection pool into the object instance of JavaBean stored procedure without disturbing JRXML file. 987 | P a g e
  5. 5. Bhushan S. Sapre, Pankaj R. Ulhe, Dr. B. B. Meshram / International Journal of Engineering Research and Applications (IJERA) ISSN: 2248-9622 www.ijera.com Vol. 2, Issue 4, July-August 2012, pp.984-988When we change stored procedure, we can compile itwithout restarting the database server. But if we 6. Ming Xue, Changjun Zhu, Design andchange the JRXML file, we need to restart Implementation of the Hibernate Persistenceapplication server to compile it. We do not need to Layer Data ReportSystem Based on J2EE,compile JRXML file as long procedure name and/or pp 232-235its parameters do not change. Therefore it is goodoption to use stored procedure to fill data in report. Books:5. CONCLUSION 7. Feng Zhang,Hong Wang,Jiao Zhu, Know- This paper mainly focuses on an open- how of Java Advanced (Beijing, Sciencesource reporting tool JasperReports and visual report Press, 2008).designer iReport. This data report system separatesreport template from report data. This helps to 8. Weiqing Sun, Java Web design andachieve flexibility in reports. The report template can development based on MVC (Beijing,be changed irrespective of the report data displayed Electronic Industry Press, 2004).by report. Stored procedures retrieve data to fill in thereport. Currently this idea has been applied to theopen-source SpringMVC framework. This data report E-References:system has helped to meet business needs of theproject and has provided a fast and scalable data 1. Official website of JasperReports.report system. http://jasperreports.sourceforge.Net/, 2002.REFERENCES 2. Reporting Made Easy with JasperReportsJournal Papers: and Hibernate 1. Rong Li, Yuewei Ding, Xiaojun, Xu, http://xml.ulitzer.com/node/171467, 2007. Dynamic Data Report Generation Technology based on XML, Micro- 3. Using JasperReports with Hibernate computer information, vol.12-3, pp.87- https://www.hibernate.org/79.html, 2007. 89,2005. 4. Stored Procedures and Functions: 2. Lei Liu, Hong Liu, Huayu Wang, The http://www.roseindia.net, 2008 research and implementation of reuse report generation system based on Component, 5. Stored Procedures: http://plsql-tutorial.com Min-microcomputer system, vol.24-4, pp.739-744,2003. 6. How to call stored procedure that returns sys_refcursor from ireport 4.5.1: 3. Wenhao Cui, The research and application http://stackoverflow.com/, 2008 of reports generation using JasperReports, Journal of Shenyang chemical Institute, 7. How to call Stored Procedures from vol.22-2, pp.176-179, 2008. JasperReports: http://itblackbelt.wordpress.com/2008/02/29 4. Li Feng, Wensheng Li, The design and /how-to-call-stored-procedures-from- implementation of J2EE-based object- jasperreports/, 2009 oriented data report system, Computer system application, vol.2, pp.57-58,2006. 8. SQL Server Stored Procedures: http://databases.about.com,2009 5. Fangxia Zhang, Renjin Zhang, The Research and Application of JasperReports in Project Management System, OSSC-2009,,pp 56-59 988 | P a g e

×