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.
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:
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.
Connect each tMysqlConnection to the relevant component in your Jobs using a Trigger > On Subjob Ok link.
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.
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.
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.
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.