Setting up the JDBC driver

JReport supports all of the current mainstream databases as well as most databases which support ODBC or JDBC drivers. For more information, refer to Supported report databases.

To connect to a database via a JDBC driver:

  1. Install the JDBC driver according to the instructions provided by the JDBC driver supplier.
  2. Edit setenv.bat for Windows or setenv.sh for Unix in <designer_install_root>\bin, by appending the class path for the JDBC driver.

Note: The step for appending the class path is very important. The same changes made to JReport Designer’s class path must be made to the class path for JReport Server too. A missing JDBC driver in the JReport start-up batch file or command line will result in a "ClassNotFoundError message" when you try to run a report. Meanwhile, if you want to use the Preview as Page/Web Report Result feature in JReport Designer, you also need to append the class path for the JDBC driver to setenv.bat/setenv.sh in <designer_install_root>\server\bin.

The following are two examples of setting up the JDBC driver.

Example 1: Installing a Sybase JDBC driver

  1. Install Sybase JDBC driver jconn2.jar.
  2. Modify setenv.bat by appending the archive file path and file name of the driver to the set ADDCLASSPATH system variable:

    set ADDCLASSPATH=%JAVAHOME%\lib\tools.jar;c:\jconnect\jconn2.jar;

Example 2: Installing an Oracle JDBC driver

  1. Install Oracle JDBC driver ojdbc6.jar.
  2. Modify setenv.bat by appending the archive file path and file name of the driver to the set ADDCLASSPATH system variable:

    set ADDCLASSPATH=%JAVAHOME%\lib\tools.jar;c:\orc\thin\lib\ojdbc6.jar;

Limiting the size of the fetch data buffer

If you are using a database which supports the JDBC method Statement.setFetchSize(), you can request the database to retrieve a specified number of rows in each read instead of all rows which minimizes memory usage. This can improve performance. It can also avoid Java heap out of memory errors when doing large queries. JReport provides a property setFetchSize in the JdbcDriversConfig.properties file for you to do this, which is located in the <install_root>\bin directory.

The following is an example of setting the setFetchSize property in the JdbcDriversConfig.properties file and detailed description of each property:

DriverName_D1 = MySQL-AB JDBC Driver
Vendor_D1 = MySql.com
Version_D1 = 3.0.8-stable ($Date: 2003/05/19 00:57:19 $, $Revision: 1.27.2.18 $)
setFetchSize_D1 = 5000

Specifying where to implement the maximum query run time and number of records

In the JdbcDriversConfig.properties file, you can also specify where the properties, Maximum Rows and Maximum Duration, will be implemented, on JReport side or on the database side. For details about usage of these two properties, see Limiting the query run time and number of records.

The following is an example of setting the two properties:

DriverName_D2 = Oracle JDBC driver
Vendor_D2 = Oracle
Version_D2 = 9.2.0.3.0 
supportMaxRowPushDown_D2 = true
supportMaxDurPushDown_D2 = true
Notes: