Skip to main content Skip to complementary content

Sharing a database connection

About this task

If you have various Jobs using the same database connection, you can factorize the connection by using the Use or register a shared DB Connection option so that the connection can be shared between parent and child Jobs.

This option has been added to all database connection components in order to reduce the number of connections to open and close.

Information noteWarning: The Use or register a shared DB Connection option of all database connection components is incompatible with the Use dynamic Job and Use an independent process to run subJob options of the tRunJob component. Using a shared database connection together with a tRunJob component with either of these two options enabled will cause your Job to fail.

The procedure below assumes that you have two related Jobs (a parent Job and a child Job) that both need to connect to your remote MySQL database.

For a complete use case, see MySQL.

To use a shared database connection in the two Jobs, to the following:

Procedure

  1. Add a tMysqlConnection (assuming that you work with a MySQL database) to both the parent and the child Job, if they are not using a database connection component.
  2. Connect each tMysqlConnection to the relevant component in your Jobs using a Trigger > On Subjob Ok link.
    Job in the design workspace.
  3. In the Basic settings view of the tMysqlConnection component that will run first, fill in the database connection details if the database connection is not centrally stored in the Repository.
  4. Select the Use or register a shared DB Connection check box, and give a name to the connection in the Shared DB Connection Name field.
    Basic settings view.
    You are now able to re-use the connection in your child Job.
  5. In the Basic settings view of the other tMysqlConnection component, which is in the other Job, simply select Use or register a shared DB Connection check box, and fill the Shared DB Connection Name field with the same name as in the parent Job.
    Information noteNote:

    Among the different Jobs sharing the same database connection, you need to define the database connection details only in the first Job that needs to open the database connection.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!