Skip to main content Skip to complementary content
Close announcements banner

Creating the Job and defining context variables

Before you begin

Create two tables named db_testing and db_production respectively in a MySQL database named db_connections, to hold the connection parameters for accessing the above mentioned databases, testing and production. Each table should contain only two columns: key and value, both of type VARCHAR. Below is an example of the content of the database tables:

db_testing:

key value
host localhost
port 3306
username root
password talend
database testing

db_production:

key value
host localhost
port 3306
username root
password talend
database production

You can create these database tables using another Talend Job that contains tFixedFlowInput and tMysqlOutput components.

Procedure

  1. Create a Job and add a tMysqlInput component and a tLogRow component onto the design workspace, and link them using a Row > Main connection.
    Screenshot of the Job in the Designer.
  2. Select the Context view of the Job, and click the [+] button at the bottom of the view to add five rows in the table to define the following variables, all of type String, without defining their values, which will be loaded dynamically at Job execution: host, port, username, password, and database.
    Screenshot of the Context view.
  3. Now create another variable named db_connection of type List Of Value.
  4. Click in the Value field of the newly created variable and click the button that appears to open the Configure Values dialog box, and click New... to open the New Value dialog box. Enter the name of one of the database tables holding the database connection details and click OK.
    Screenshot of the New Value dialog box.
  5. Click New... again to define the other table holding the database connection details. When done, click OK to close the Configure Values dialog box.

    Now the variable db_connection has a list of values db_testing and db_production, which are the database tables to load the connection parameters from.

  6. Select the Prompt check box next to the Value field of the db_connection variable to show the Prompt fields and enter the prompt message to be displayed at the execution time.
    Screenshot of the Context view with the prompt message for the db_connection variable.

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 – let us know how we can improve!