KAN
KAN

Reputation: 11

connecting several database using tFileInputProperties in Talend

I'm completely new to talend and currently I need to build a job that reads params values like

  1. Database Name
  2. Server Name
  3. Host Name
  4. Password
  5. username

From a property file and passed those values in a tPostgresqlConnection Component.

This is what I have try so far

tFileInputProperties -------> tContextLoad ------> tPostgresqlConnection

Talend Job Image: Talend Job Image

Problem is the job is taking only one database connection instead of looping for all databases connection that I have defined in the file properties.

Can someone advice how i can create a Job that will loop params values on the tPostgresqlConnection component?

Upvotes: 0

Views: 482

Answers (1)

Ibrahim Mezouar
Ibrahim Mezouar

Reputation: 4051

I suggest you create a properties file per database connection, and in each file you define your connection parameters :

server=myServer
port=myPort
user=myUser
password=myPassword
...

(Make sur your parameters have the same keys across files)

Then you can do something like this :

tFileList -- Iterate -- tFileInputProperties -- Main -- tContextLoad -- OnComponentOk --  tRunJob

the tContextLoad component will populate the context parameters (which need to exist in your main job and child job).

In the tRunJob, you encapsulate your job logic : connect to your database using your connection parameters (server, port, user..etc) passed down from the parent job, do what you need to do, and close your connection at the end of your job.

Make sure to check the option "Transmit whole context" in your tRunJob component settings.

Of course you can do it all in a single job using OnSubjobOk links, but I find this more readable (and easily maintainable)

Upvotes: 0

Related Questions