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:
Download the JReport install program jrpsetup.exe
from the Jinfonet web site:
(http:\www.jinfonet.com\jrptbeta.htm).
- Run jrpsetup.exe and follow the prompts to install.
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.
- To install the Shortcut on the Desktop, drag and drop the Shortcut to
the Desktop.
- 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.
- Click the Start button and choose Settings and then Control Panel.
- Open the 32 Bit ODBC Data Source Administrator
which is found in the Control Panel.
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:
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.

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.
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:
- Start up JReport using one of the methods above.
- In the initial Choose Report dialog, make sure that
catalog in use is:
C:\JReport\Demo\Reports\Tutorial\Tutorial.cat
- 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:
- 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.
- 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:
- Install the JDBC driver according to the instructions of the
JDBC driver provider.
- 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.
- Connect to a database via the JDBC driver in JReport.
- Start up JReport. Click the Cancel
button in the Choose Report Dialog.
- Click the File menu and select the New
Catalog menu item. A new Catalog Browser will pop up.
- 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.
- Uncheck the checkbox Use ODBC-JDBC bridge,
which was checked by default.
- 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.)
- Enter your User Name and Password
for that connection.
- Check the JDBC Driver checkbox.
- Enter the JDBC driver class name in the JDBC
Driver edit field.
- 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:
- 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.)
- 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" ...
- Connect to the database via the JDBC driver in JReport.
- Start up JReport. Click the Cancel
button in the Choose Report Dialog.
- Click the File menu and select the New
Catalog menu item. After entering a new catalog name, a new Catalog Browser
will pop up.

- 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.
- Check off the checkbox Use ODBC-JDBC bridge
and enter jdbc:sybase:Tds:SybServer:5000/pubs2 in the URL field.

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

- Another way to specify the JDBC driver name is to edit and add
the driver name to the file jreport\bin\jdbcdrivers.properties.
- Click the OK button. Then use the Add
Table dialog box to add tables into the catalog.
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:
- Install Oracle JDBC driver classes111.jar
. (Please refer to the user's guide of Oracle installation for further detail.)
- 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" ...
- Connect to the database via the JDBC
driver in JReport.
- Start up JReport. Click the Cancel
button in the Choose Report Dialog.
- Click the File menu and
select the New Catalog menu item. After entering a new catalog
name, a new Catalog Browser will pop up.

- 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.
- Check off the checkbox Use
ODBC-JDBC bridge and enter jdbc:Oracle:thin:@p02_wuhb:1521:orcl
in the URL field.
- 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.

- Another way to specify the JDBC driver name is
to edit and add the driver name to the file jreport\bin\jdbcdrivers.properties.
- Click the OK button, then
use the Add Table dialog box to add tables into the catalog.
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.
- Install Interbase JDBC driver interclient.jar.
(Please refer to the user's guide of Interbase client installation for further detail.)
- 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" ...
- Connect to the database via the JDBC
driver in JReport.
- Start up JReport. Click the Cancel
button in the Choose Report Dialog.
- Click the File menu and
select the New Catalog menu item. After entering a new catalog
name, a new Catalog Browser will pop up.

- 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.
- Check off the checkbox Use ODBC-JDBC
bridge and enter jdbc:interbase://InterbaseServer/c:\demo.gdb in
the URL field.
- 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.

- Another way to specify the JDBC driver name is
to edit and add the driver name to the file jreport\bin\jdbcdrivers.properties.
- 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.