Kettle PDI, Named Parameters, and Generic Database Connections

Kettle / PDI Generic SQL Server JTDS database with parameters and a Generic SQL Server Database Connection

The purpose of using named parameters is to abstract out what parts of a database connection change, from one environment to another, and make that part of a configuration that can be maintained elsewhere.  For example,  for a given ETL to extract Appointment data, it might need to connect to different database servers, databases, and use different credentials in Development, QA, and Production.

This example makes the database connection more generic than necessary for that purpose, just as a learning exercise.

First… Define a database connection and use replacement variables for all of the parameters. In this example, the following parameters are used.

  • DB_PW

For demonstration purposes, the generic database connection is named “GENERIC_JTDS” and uses the Microsoft SQL Server JTDS database driver.



In the job’s settings, define the same parameters it needs to connect to the database.


As an example, I have a created a job with a “Check Database Connection” component. “Check Db Connections direct VAR” uses the  “GENERIC JTDS”  database connection.



Here are the settings for the step “Check Db connections direct VAR”


Now…. I can pass in all the attributes / parameters for any SQL Server connection, into the test Job “var-conn-generic.kjb”,  into Kitchen.  Or, I can specify the default parameter values when I run the job from Spoon.

To run the job from the Spoon GUI, run it and specify the values for the parameters. 2013-12-17_0917-execute-job


Command Line, using

./ -file=/example/data-integration/var-conn-generic-test.kjb

Example Output

2013/12/16 13:50:45 - Kitchen - Start of run.
2013/12/16 13:50:47 - var-conn-generic-test - Start of job execution
2013/12/16 13:50:47 - var-conn-generic-test - Starting entry [Check Db connections direct VAR]
2013/12/16 13:50:47 - var-conn-generic-test - Starting entry [Write To Log direct VAR]
2013/12/16 13:50:47 - Params Received - DB_HOST ${DB_HOST}
2013/12/16 13:50:47 - Params Received - DB_USER ${DB_USER}
2013/12/16 13:50:47 - Params Received - DB_PW ${DB_PW}
2013/12/16 13:50:47 - var-conn-generic-test - Finished job entry [Write To Log direct VAR] (result=[true])
2013/12/16 13:50:47 - var-conn-generic-test - Finished job entry [Check Db connections direct VAR] (result=[true])
2013/12/16 13:50:47 - var-conn-generic-test - Job execution finished
2013/12/16 13:50:47 - Kitchen - Finished!
2013/12/16 13:50:47 - Kitchen - Start=2013/12/16 13:50:45.938, Stop=2013/12/16 13:50:47.546
2013/12/16 13:50:47 - Kitchen - Processing ended after 1 seconds.

Comments |0|

Legend *) Required fields are marked
**) You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
In category: Uncategorized
Tagged with: , , ,