Passing a session to a child job
Following on from the previous task, this recipe shows how a common connection can be passed from a parent job to a child job.
Getting ready
Open the job jo_cook_ch07_0070_databaseSessionParent
, which is the same as the completed version from the previous recipe, but with the main process replaced with a child job. On inspection you should see that the child job has a connection set up and it is the same connection as the parent job.
How to do it…
The steps to be performed are as follows:
Run the job. If you inspect the database table
testSessionChild
, you will see that no records have been added to the database.Open
tMysqlConnection
in the parent job.Tick the box Use or register a shared DB Connection, and set the Shared DB Connection Name to
"cookbook"
, as shown in the following screenshot:Repeat the same for the connection in the child job.
Run the job. When you now inspect the database table
testSessionChild
, you will see that the records have been added to...