Lesson 1:   Installing and Starting JReport

Important: The following instructions apply to Window 95/98/NT.  It is also assumed that JReport will be installed in c:\jreport.

In this lesson you will learn how to:

To install JReport:

  1. Download the JReport install program jrpsetup.exe from the Jinfonet web site:
    (http:\www.jinfonet.com\jrptbeta.htm).

  2. Run jrpsetup.exe and follow the prompts to install.

  3. You can create a shortcut to the batch file created by the setup program.  On the desktop, double click to open My Computer and then go to (C):\JReport\bin\JReport.bat.  Right click the JReport.bat and select Create Shortcut(s) Here.

  4. To install the Shortcut on the Desktop, drag and drop the Shortcut to the Desktop.

  5. To install the Shortcut to the Start Menu, drag and drop the Shortcut to:
    C:\Windows\Start Menu\Programs

To setup the ODBC Data Source:

You need to create a data source before you can view the sample reports in c:\jreport\demo\reports. To do this you should have Microsoft Access ODBC driver (or an equivalent driver) installed and create a data source pointing to the demo database.

  1. Click the Start button and choose Settings and then Control Panel.

  2. Open the 32 Bit ODBC Data Source Administrator which is found in the Control Panel.

  3. Click the Add button and select the Microsoft Access Driver (*.mdb).  Click Finish to display the ODBC Microsoft Access Setup dialog.  Complete the dialog as shown below:

  4. Click the Select button and when the Select Database dialog appears, browse to the demo database c:\jreport\demo\db\demo.mdb, as shown below.  

    wpe4.gif (9052 bytes)


  5. Click OK on each of the three dialogs to create the data source and exit the ODBC Administrator.

For more information about how to install ODBC drivers and create data sources, refer to your Windows NT, Windows 95, or Windows 98 online help, or contact your ODBC vendor.

To run JReport:

You can run JReport using either the Shortcut you created or the batch file created by the setup program.

To run the batch file:
>From the desktop, double click My Computer, then go to C:\JReport\bin\JReport.bat, run JReport.bat
.
Or from an MS-DOS command prompt, issue the commands:

c: cd\jreport\bin jreport

Getting ready to view the example reports:

JReport organizes report files and related objects into catalogs.  You must open a catalog before you can view, change, and create reports.  A set of example reports are provided in the catalog called SalesManagement during the setup process.  To open this catalog:

  1. Start up JReport using one of  the methods above.
  2. In the initial Choose Report dialog, make sure that catalog in use is:
    C:\JReport\Demo\Reports\Tutorial\Tutorial.cat
  3. If the catalog is not properly set, press the Browse button to select the Tutorial.cat catalog from the Open dialog.

To view one of the example reports, click the Existing tab and select one of the reports in the list.  As you view the design and various elements of a report, there will be two browsers you can use to inspect the report:

  1. Catalog Browser:  Contains all the resources, organized into three tabs which you can use to build a report.  By default, the base query for this report is expanded.  Data fields that are currently used in the report are shown with a check mark.  Frequently used objects are also accessible from icons on a tool bar, which can be double-clicked to detach, resize and move to a convenient location.
  2. Report Inspector:  All the objects in the current report are organized into a tree structure on the top part of the Report Inspector window, with the currently selected object highlighted.  The properties and values of the current report object are shown on the bottom part.  For most values, clicking the value will let you change it or select a new value from a dialog.

Now you may proceed to Lesson 2 to learn how to design a simple report using the Report Wizard.  However, if you are using a database system that requires a native JDBC driver, you should follow the instructions below to properly install the JDBC driver.

To show you how to connect to a database via a JDBC driver, we first provide a summary of the steps needed, which is followed by two examples.  Here are the steps: 

  1. Install the JDBC driver according to the instructions of the JDBC driver provider.
  2. For JReport Workbench, edit %installroot%\bin\jreport.bat to append the classpath for the JDBC driver.  %installroot% is the path where you installed JReport Workbench.  Likewise, for JReport Server, edit %installroot%\bin\jrserver.bat to append the classpath for the JDBC driver.
  3. Connect to a database via the JDBC driver in JReport.
    1. Start up JReport.  Click the Cancel button in the Choose Report Dialog.
    2. Click the File menu and select the New Catalog menu item.  A new Catalog Browser will pop up.
    3. Click the Connection icon and note that the New Connection button will appear in the Catalog Browser tool bar.  Click the New Connection button to pop up the Connection dialog box.
    4. Uncheck the checkbox Use ODBC-JDBC bridge, which was checked by default.
    5. Enter the URL of the database in the URL field of the Connection dialog box.  For the format of the URL please refer to the instructions of your JDBC driver.  (An example is provided below.)
    6. Enter your User Name and Password for that connection.
    7. Check the JDBC Driver checkbox.
    8. Enter the JDBC driver class name in the JDBC Driver edit field.
    9. Click the OK button.  The Add Table dialog box will appear to let you add tables into the catalog.

How to install a Sybase JDBC Driver:

The following example illustrates how to connect to a Sybase database server with the name SybServer, port No. 5000, database pubs2, user ID sa, and password 123456:

  1. Install Sybase JDBC driver Jconnect.class, run the SQL file sql_server.sql to create the JDBC metadata tables. (Please refer to the user's guide of Sybase installation for further details.)
  2. Edit Jreport\bin\Jreport.bat to append the archive file of the driver to the classpath:

    Change:  ... -classpath "e:\JReport\lib\report.zip; ... lib\i18n.jar" ...
    To : ... -classpath "e:\JReport\lib\report.zip;c:\jconnect\classes; ... lib\i18n.jar" ...

  3. Connect to the database via the JDBC driver in JReport.
    1. Start up JReport.  Click the Cancel button in the Choose Report Dialog.
    2. Click the File menu and select the New Catalog menu item.  After entering a new catalog name, a new Catalog Browser will pop up.

      figure1.gif
  4. Click the Connection icon and click the New Connection button on the Catalog Browser tool bar to pop up the Get JDBC Connection Information dialog box.
  5. Check off the checkbox Use ODBC-JDBC bridge and enter jdbc:sybase:Tds:SybServer:5000/pubs2 in the URL field.

    Figure3.gif (4692 bytes)

  6. Enter the User ID sa and password 123456.   Check the JDBC Driver checkbox. Enter the JDBC driver class name com.sybase.jdbc.SybDriver in the JDBC Driver edit field.

    Figure5.gif (4910 bytes)

  7. Another way to specify the JDBC driver name is to edit and add the driver name to the file jreport\bin\jdbcdrivers.properties.
  8. Click the OK button.  Then use the Add Table dialog box to add tables into the catalog.

How to install an Oracle JDBC driver:

The following example illustrates how to connect to an Oracle database server with the name p02_wuhb, port No. 1521, database orcl, user ID scott, and password tiger:

  1. Install Oracle JDBC driver classes111.jar . (Please refer to the user's guide of Oracle installation for further detail.)
  2. Edit Jreport\bin\Jreport.bat to append the archive file of Oracle thin driver to classpath:

    Change: ... -classpath "e:\JReport\lib\report.zip; ... lib\i18n.jar" ...
    To : ... -classpath "e:\JReport\lib\report.zip;
    c:\orc\thin\lib\classes111.jar; ... lib\i18n.jar" ...

  3. Connect to the database via the JDBC driver in JReport.
    1. Start up JReport.  Click the Cancel button in the Choose Report Dialog.
    2. Click the File menu and select the New Catalog menu item.  After entering a new catalog name, a new Catalog Browser will pop up.

      figure1.gif
  4. Click the Connection icon and click the New Connection button on the Catalog Browser tool bar to pop up the Get JDBC Connection Information dialog box.
  5. Check off the checkbox Use ODBC-JDBC bridge and enter jdbc:Oracle:thin:@p02_wuhb:1521:orcl in the URL field.
  6. Enter the User ID scott and password tiger.  Check the JDBC Driver checkbox.  Enter the JDBC driver class name oracle.jdbc.driver.OracleDriver in the JDBC Driver edit field.

    orajdbc.gif (4509 bytes)

  7. Another way to specify the JDBC driver name is to edit and add the driver name to the file jreport\bin\jdbcdrivers.properties.
  8. Click the OK button, then use the Add Table dialog box to add tables into the catalog.

How to install a Interbase JDBC driver:

The following example illustrates how to connect to an Interbase database server with the name InterbaseServer, database demo.gdb, user ID TUTORIAL, and password TUTORIAL.

  1. Install Interbase JDBC driver interclient.jar. (Please refer to the user's guide of Interbase client installation for further detail.)
  2. Editing Jreport\bin\Jreport.bat to append the archive file of Interbase thin driver to classpath:

    Change: ... -classpath "e:\JReport\lib\report.zip; ... lib\i18n.jar" ...
    To : ... -classpath "e:\JReport\lib\report.zip;
    c:\interbase\lib\interclient.jar; ... lib\i18n.jar" ...

  3. Connect to the database via the JDBC driver in JReport.
    1. Start up JReport.  Click the Cancel button in the Choose Report Dialog.
    2. Click the File menu and select the New Catalog menu item.  After entering a new catalog name, a new Catalog Browser will pop up.

      figure1.gif
  4. Click the Connection icon and click the New Connection button on the Catalog Browser tool bar to pop up the Get JDBC Connection Information dialog box.
  5. Check off the checkbox Use ODBC-JDBC bridge and enter jdbc:interbase://InterbaseServer/c:\demo.gdb in the URL field.
  6. Enter the User ID TUTORIAL and password TUTORIAL.  Check the JDBC Driver checkbox.  Enter the JDBC driver class name interbase.interclient.Driver in the JDBC Driver edit field.

    intjdbc.gif (4509 bytes)

  7. Another way to specify the JDBC driver name is to edit and add the driver name to the file jreport\bin\jdbcdrivers.properties.
  8. Click the OK button, then use the Add Table dialog box to add tables into the catalog.

Now that your data source is all set up, you may proceed to Lesson 2 where you will learn how to design a simple report using the Report Wizard.