Previous Page Next Page
Setting Up a JDBC Connection
This procedure assumes you have set up the JDBC driver as described in the previous topic.
To connect a JReport catalog with a relational database via a JDBC driver:
- Create a catalog or open a catalog.
- In the Catalog Manager, right-click the node of a data source and select New JDBC Connection from the shortcut menu. Click JDBC in the Select Connection Type dialog.
If you want to set up the connection in a new data source in the catalog, select any of the existing catalog data sources, click New Data Source on the Catalog Manager toolbar, then in the New Data source dialog, specify the name of the data source, select the JDBC connection type and click OK.
- In the Get JDBC Connection Information dialog, provide the necessary information to connect with the database. If your database has some special requirements, you can click the More Options button to modify the options according to your requirements. Click Test Connection
to test whether the JDBC information you provide is available.

- Click OK to set up the connection, and you will be prompted with a message box showing the status of connecting to the JDBC driver.
Upon the finishing setting up the connection, the Add Tables dialog is displayed, prompting you to add tables from the database to the connection. If you want to add tables at a later date, click Done.
You have four ways to set up a JDBC connection:
- Setting up by adding an existing connection
- In the Get JDBC Connection Information dialog, select the connection from the Connection List. This list contains previously added connection information.
- The JDBC URL and JDBC driver name will then appear in the corresponding text fields. Click OK.
Note: The format of the connection information should be JDBC URL/(JDBC Driver Name). For example: jdbc:odbc:jinfonet/(sun.jdbc.odbc.JdbcOdbcDriver)
.
- Setting up an ODBC connection
- In the Get JDBC Connection Information dialog, uncheck the Driver checkbox and check Use ODBC Data Source box.
- Enter the ODBC data source name in the DSN Name field.
- Input the user name and password to enable accessing the database through the ODBC data source, and then click OK.
Notes:
- The ODBC-JDBC bridge is not included in Java JDKs after version 7. If you are using JDK 8 or later you will get an error that "No suitable driver found for jdbc:odbc".
- The JDK that JReport uses must match the ODBC data source that the operating system uses. For example, 32-bit ODBC data source can be connected by 32-bit JDK only.
- Setting up a JDBC connection
- In the Get JDBC Connection Information dialog, specify the driver in the Driver text field.
The most common error is a ClassNotFound error which is caused by the driver class name not being found in the classpath. If you have included the JDBC driver jar file in the setenv.bat/setenv.sh file then it might be an error in the class name. The class name is case sensitive so if it says OracleDriver it must be the exact case. The driver name is not the name of the JDBC driver jar file.
- In the URL text field, specify the URL of the JDBC driver.
The URL format is regulated by the driver itself. That is, different drivers have different URL formats.
The format of the driver template in JReport Designer jdbcdrivers.properties is jdbc.drivers=JDBCDriverName:JDBCDriverName:...
where, JDBCDriverName is the JDBC driver name that can be auto-loaded when JReport starts up and ":" is the delimiter between two driver names. JReport will search from the beginning of the classpath and find one that contains the class specified.
Below is an example of the jdbcdrivers.properties file which specifies an Oracle thin driver and an Interbase thin driver:
jdbc.drivers=oracle.jdbc.driver.OracleDriver:interbase.interclient.Driver
- Input the user name and password respectively, and then click OK.
Tip: After entering the JDBC URL, user name and password, you can leave the Driver text field empty and instead supply it in the property file jdbcdrivers.properties which is located in the <install_root>\bin
directory.
- Setting up a connection via the WebLogic 6.1 connection pool
- In the Get JDBC Connection Information dialog, check the Use Connection Pool checkbox. The string weblogic.jinfonet.pool.Driver will automatically be displayed in the Driver text field.
- In the URL text field, specify the URL of the JDBC driver.
- Input the user name and password respectively, and then click OK.
Via specific JDBC drivers, you can set up connections which connect JReport Designer to different report databases. The following are some examples.
Example 1: Via the Oracle JDBC Driver
Example 2: Via the MySQL JDBC Driver
Example 3: Via SQL Server
Example 4: Via DB2
Example 5: Via Informix
Example 6: Via PostgreSQL
Example 7: Via WebLogic 6.1 Connection Pool
Example 8: Via Vertica
Example 9: Via Amazon RDS
Example 10: Via RedShift
Previous Page Next Page