### Setting up a JDBC connection

This procedure assumes you have set up the JDBC driver as described in the previous task.

Note: 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 first and find one that can work with the driver, URL, and user name and password in the catalog.

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`

To set up a JDBC connection:

1. Create a catalog or open a catalog, then in the Data tab of the Catalog Browser, right-click the node of a data source and choose Add JDBC Connection from the shortcut menu.

   If you want to set up the connection by adding a data source to an existing catalog and then defining the connection on the data source, open the catalog, select any data source contained in it, click the New Data Source button on the Catalog Browser toolbar, then in the New Data source dialog, specify the name of the data source, select the JDBC connection type and click OK.

2. In the Get JDBC Connection Information dialog, specify the options as required. See the dialog.

3. 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. Then you can add tables stored in the database to the catalog in the displayed Add Table dialog.

You have four ways to set up a JDBC connection:

- Setting up by adding an existing connection
  1. In the Get JDBC Connection Information dialog, select the connection from the Connection List. This list contains previously added connection information.
  2. 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
  1. In the Get JDBC Connection Information dialog, uncheck the Driver checkbox and check Use ODBC Data Source box.
  2. Enter the ODBC data source name in the DSN Name field.
  3. Input the user name and password to enable accessing the database through the ODBC data source, and then click OK.

  Note: 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
  1. In the Get JDBC Connection Information dialog, specify the driver in the Driver text field.
  2. In the URL text field, specify the URL of the JDBC driver.
  3. 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.

- Setting up a connection via the WebLogic 6.1 connection pool
  1. 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.
  2. In the URL text field, specify the URL of the JDBC driver.
  3. Input the user name and password respectively, and then click OK.

Tips:

- Upon the finishing of setting up the connection, the Add Table dialog will be displayed, prompting you to add tables from the database to the connection. If you want to add tables at a later date, click Done.
- When creating any of the above connections, if your database has some special requirements, you can click the Options button to modify the options according to your requirements.

The following examples show how to set up connections via specific JDBC drivers:

- Example 1: Setting up a connection via the Oracle JDBC driver
- Example 2: Setting up a connection via the Sybase JDBC driver
- Example 3: Setting up a connection via WebLogic 6.1 Connection Pool
- Example 4: Setting up a connection via Vertica
- Example 5: Setting up a connection via Amazon RDS
- Example 6: Setting up a connection via RedShift