## Configuring dynamic connections

A dynamic connection is a group of connection properties that can be used to override the original data source connections in a catalog. The server administrator can modify some of the original catalog connection properties, and then save these modified properties as a dynamic connection property. For a dynamic connection, the administrator can define a database user mapping table which is a table containing the columns: SID, database user, and database password. JReport Server manages the dynamic connections in the server system database.

When running a report or scheduling a report to run, if there are multiple dynamic connections available to the log-in user, the user needs to select one. Then the server will pass the changed connection properties of the selected dynamic connection into the report engine. The report engine will merge the changed properties with the other original catalog connection properties to setup the database connection.

Dynamic connections are categorized at the organization level. If the system administrator creates a dynamic connection, the connection maps to no organization. If an organization administrator creates a dynamic connection, the connection maps to the organization. If a dynamic connection is defined in an organization, all users/groups/roles must be from the same organization. If a connection is defined in non-organization, all users/groups/roles must be from non-organizations. System administrator can define, view and edit all the dynamic connections.

### Creating a dynamic connection

1. On the JReport Administration page, click Configuration on the system toolbar and then select Dynamic Connections from the drop-down menu.
2. In the Dynamic Connections panel, click the Add Dynamic Connection link. The Add Dynamic Connection dialog appears. See the dialog.

3. Click Browse to select a catalog in the Select Catalog dialog.
4. From the Data Source Name drop-down list, select a data source available in the selected catalog.
5. From the Connection Name drop-down list, select a connection to connect to the data source.
6. Click Properties to expand the properties table. To change a property's value, first select the checkbox beside it, and then enter a value in the text box or select a value from the drop-down list as required.
7. Click Add Database User Mapping to define the mapping relationship between SID and database user/password. A mapping row will be added in the mapping table. From the SID drop-down list, select a user, role, or group name. Double-click in the text box of Database User and Database Password and you can then type in database user name and password. Then click Test Connection to test whether the user name and password can connect to the database.

   Within a dynamic connection, make sure that an SID is mapped to only one pair of database user and name.

8. Click OK to create the dynamic connection which will be listed in the Dynamic Connections panel.

### Managing dynamic connections

In the Dynamic Connections panel, the administrator can perform the following actions:

Searching for a dynamic connection

First select a search category from the drop-down list, then type the text in the text box and click to start the search. The x button in the text box is used to clear the input text. After the results are filtered, to return to the state before search, click x in the text box.

There are the following search categories:

- Catalog
  Searches for catalogs.
- Connection Name
  Searches for connection names.
- SID
  Searches for SIDs.
- Database User
  Searches for database users.

For example, in order to find the dynamic connections which use the catalog SampleReprts.cat, you can select Catalog from the search category drop-down list and input sam as the keyword. JReport will search for sam in the Catalog column and the dynamic connections whose catalogs contain the text will be kept in the dynamic connection table.

Editing a dynamic connection

Click the connection name to open the Edit Dynamic Connection dialog, in which you can edit the properties of the dynamic connection as you want.

Deleting dynamic connections

Select the checkboxes ahead of the dynamic connections and then click Delete. To delete all the dynamic connections at a time, select the checkbox on the column header and then click Delete.

### Applying dynamic connections

One user can have multiple dynamic connections for one catalog data source. When running a report, if there are multiple dynamic connections for the log-in user:

- For advanced run, the user needs to select a dynamic connection from the available ones.
- For schedule run, if the selected dynamic connection cannot be found when running reports, then the first available dynamic connection will be applied.
- For direct run, link reports, API run, getting parameter values from the database, and getting filter values from the database, the first available dynamic connection is applied automatically.

### Connection priority

The priority from high to low is: dynamic connection > the connection specified in datasource.xml > catalog connection.

###### Related topics:

- Dynamic connection API