How to share a database connection - 6.1

Talend Real-time Big Data Platform Studio User Guide

EnrichVersion
6.1
EnrichProdName
Talend Real-Time Big Data Platform
task
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

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.

Warning

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.

Assume that you have two related Jobs (a parent Job and a child Job) that both need to connect to your remote MySQL database. To use a shared database connection in the two Jobs, to the following:

  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.

  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.

    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.

    Note

    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.

For a complete use case, see the scenario of the tMysqlConnection component showing how to share a database connection between different Jobs in Talend Components Reference Guide.

For more information about how to use the Connection components, see Talend Components Reference Guide.