
Extract information from databases using BIRT and Eclipse Generate fancy summaries, charts, and analysis for your reports Skill Level: Intermediate Tyler Anderson ([email protected]) Freelance writer Freelance 24 Jan 2006 Business reporting and analysis is a complex process that is difficult to get perfect when you want to produce a professional-looking report. Even more difficult is regularly repeating the exercise with new or updated data. The Business Intelligence and Reporting Tools (BIRT) is a suite of plug-ins for Eclipse that allows you to extract information from your databases, analyze that information, then generate summaries, charts, and analysis for your reports. In this tutorial, you'll learn how to use BIRT in your Java™ 2 Enterprise Edition (J2EE) applications by creating and developing reports with BIRT using the Eclipse Rich Client Platform (RCP) technology. Section 1. Before you start If you have programs that collect or generate data and you need that data analyzed using various reports, this tutorial can help you get a good understanding of using Business Intelligence and Reporting Tools (BIRT). This tutorial assumes basic knowledge of Eclipse and Apache Derby. Testing of the database is implemented by deploying the example application on Apache Geronimo. About this tutorial In this tutorial, you'll learn how to use BIRT in your J2EE applications by creating and developing reports using BIRT and Eclipse's Rich Client Platform (RCP) technology. You will install BIRT and create your first report that will interface with Extract information from databases using BIRT and Eclipse © Copyright IBM Corporation 1994, 2008. All rights reserved. Page 1 of 33 developerWorks® ibm.com/developerWorks and source its data from a Derby database, and build subsequent reports that analyze data from the same data set at a different angle. An example application will be created that collects data from bank transactions. Tellers and bank managers will enter a transaction using a Web browser. A transaction includes the bank employee's title, deposit or withdrawal amount, and date. The end result will be that the data can be analyzed online, anytime, at several angles. Thus, throughout this tutorial, you will be the "bank manager," and you will use BIRT to view and analyze the transactions performed at your bank. Prerequisites The following tools are needed to follow along. Note that this was written using a Microsoft® Windows® machine. However, the differences in details for following along on another machine should be minor. • Eclipse and BIRT -- This tutorial uses the BIRT RCP Report Designer V1.0.1. This version uses RCP. The BIRT RCP build provides everything you need to use BIRT, including BIRT V1.0.1, Java 2 JDK V1.4.2, Eclipse Platform Runtime Binary V3.1, GEF Runtime V3.1, and EMF V2.1.0. You just unzip the download and away you go. Download the BIRT RCP Report Designer from the BIRT Release Build page. • BIRT Report Engine -- You need the BIRT Report Engine to be able to view BIRT reports. • Geronimo -- This tutorial uses Geronimo M5 to deploy the sample application, along with the embedded BIRT report objects to view the reports. • Java -- Both BIRT, Geronimo, and the example application require Java technology. Plus, the example application requires J2EE for the servlet you'll create. This tutorial uses Java V1.4.2_09 and J2EE V1.4. However, any version higher than these should suffice. Download the all-in-one Java technology bundle. • Derby -- Download Derby and be sure that the .jars you receive are added to your CLASSPATH. • DB2 Drivers -- This tutorial uses the IBM DB2® universal drivers for connecting to Derby. • Ant -- You need Ant to build the example application because it simplifies the build process of WAR files for Geronimo. Section 2. Overview Extract information from databases using BIRT and Eclipse Page 2 of 33 © Copyright IBM Corporation 1994, 2008. All rights reserved. ibm.com/developerWorks developerWorks® This section gives a high-level overview of what you will learn throughout this tutorial. BIRT reports Traditional reports allow businesses to graphically display data that is readable to other people. BIRT helps automate the processing of creating reports in deployed J2EE applications. In this tutorial, you will learn how to create a report that will be deployed with your application. Example application When customers go to banks and withdraw or transfer money, the transaction is usually performed by a bank employee. The example application for this tutorial is a user interface (UI) that takes in transaction details and stores them in a Derby database. The recorded transaction details include transaction date, employee title, employee number, transaction type, amount deposited or transferred, etc. Analyzing data With the example application taking information and storing it in the database, the data is in its most raw form, without a feasible organization for viewing in a manner that would make sense. The BIRT reports you develop will be used to analyze this data. Each type of report covered will allow you to view and subsequently analyze the data contained in the database. Embedding BIRT objects in the application Once the BIRT reports and the example application have been completed, the BIRT objects are ready to be embedded within your application. This will allow you, the bank's manager, to readily see the trends of the transactions that occur within your bank. You will gain knowledge that will allow you to make the decisions to change trends for the better, and improve productivity and performance at your bank. Section 3. Derby: Setting up In this section, you will create and initialize the Derby database with test data for use in BIRT. You'll use the built-in Derby database within Geronimo through Geronimo's network server. You'll use this same database when you deploy your application on Geronimo, so it makes sense to use the built-in database. Setting up Geronimo for Derby Extract information from databases using BIRT and Eclipse © Copyright IBM Corporation 1994, 2008. All rights reserved. Page 3 of 33 developerWorks® ibm.com/developerWorks Since you will use the built-in Derby database in Geronimo for BIRT, you need the right drivers. There are a couple .jars you need to add to Geronimo: the IBM DB2 JDBC Universal Drivers. You should have them now (see Prerequisites). Unzip the .zip file you get from IBM. Take the two .jar files in the lib directory -- db2jcc.jar and db2jar_license_c.jar -- and place them in the <geronimo-install-dir>/repository/org.apache.derby/jars directory of your Geronimo installation. Geronimo's all set! Start Geronimo by opening up a console and typing: java -jar <geronimo-install-dir>/bin/server.jar The Derby network server running on Geronimo is now ready and listening. Next, you'll connect to the network server to create and initialize the database. Creating the Derby database With the network server running, you're ready to create the database. Open a console and type: java org.apache.derby.tools.ij This fires up the Derby ij tool, and takes you to the ij prompt. Create the database by typing the following at the ij prompt: connect 'jdbc:derby:net://localhost:1527/BANK;\ create=true:user=bankuser;password=bankpass;'; This connects to the Derby network server running on Geronimo, as well as a new BANK database. You will now be able to connect to and reference it from within BIRT. Now we create and initialize the table. Creating and initializing the transactions table The transactions table will house all information on transactions performed at your bank. Create the transactions table at the ij prompt by typing the following, as shown in Listing 1. Listing 1. Creating the transactions table Extract information from databases using BIRT and Eclipse Page 4 of 33 © Copyright IBM Corporation 1994, 2008. All rights reserved. ibm.com/developerWorks developerWorks® create table transactions (transactionid integer not null generated always as identity (start with 1, increment by 1), employeeid integer not null, employeetitle varchar(50), transactiondate varchar(10), transactiontype varchar(50), amount integer, transactionSrc varchar(50), transactionDst varchar(50)); You just created the transactions table successfully. You'll need to fill it with test data for your reports, so execute the next query in the same ij prompt, as shown in Listing 2. Listing 2. Inserting records into the transactions table insert into transactions (employeeid, employeetitle, transactiondate, transactiontype, amount, transactionSrc, transactionDst) values (201, 'LoanOff', '12-08-2005', 'D', 7845, 'Customer', '651232135'), (203, 'Teller', '12-08-2005', 'T', 7123, '453780785', '864513215'), (204, 'Teller', '12-08-2005', 'W', 3564, '684612312', 'Customer'), (203, 'Teller', '12-08-2005', 'D', 1546, 'Customer', '054537563'), (202, 'SrTeller', '12-08-2005', 'D', 8769, 'Customer', '054537563'), (203, 'Teller', '12-09-2005', 'W', 9753, '754350324', 'Customer'), (201, 'LoanOff', '12-09-2005', 'D', 6482, 'Customer', '878505456'), (203, 'Teller', '12-09-2005', 'D', 4657, 'Customer', '040740075'), (204, 'Teller', '12-09-2005', 'T', 3542, '192837247', '075663333'), (203, 'Teller', '12-09-2005', 'D', 4075, 'Customer', '054537563'), (202, 'SrTeller', '12-09-2005', 'W', 23, '153057753', 'Customer'), (203, 'Teller', '12-09-2005', 'D', 1, 'Customer', '871532404'), (203, 'Teller', '12-10-2005', 'D', 4687, 'Customer', '975434231'), (204, 'Teller', '12-10-2005', 'T', 4578, '456213546', '075275705'), (201, 'LoanOff', '12-10-2005', 'D', 9946, 'Customer', '054537563'), (203, 'Teller', '12-10-2005', 'W', 1572, '468734234', 'Customer'), (203, 'Teller', '12-10-2005', 'D', 999, 'Customer', '345357477'), (202, 'SrTeller', '12-11-2005', 'D', 2457, 'Customer', '875725075'), (204, 'Teller', '12-11-2005', 'W', 7974, '643024563', 'Customer'), (204, 'Teller', '12-11-2005', 'T', 500, '23049834', '23049234'); You should have 20 records in the transactions table that you will use as your test data. Next, you'll get into the BIRT RCP Report Designer, and analyze this data.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages33 Page
-
File Size-