Is there a way to pass db connection during runtime?
We are developing an ETL application which will be deployed on several servers. The database connections for the source and target are not known in advance. We plan to use another java app to call the ETL app and pass db connection information during runtime. Is this possible with Talend? Any suggestions would be very helpful. Thanks
Well, of course.
You can use context variables as your database connection parameters or read them from a file to store as global variables.
If your set of possible connections environnment is clear, you can even predefine named set of context variables, and you decide which to use at launch.
neeraj, When you create the DB Connection, you can see the button "export to context". Click on this button, your DB connextion with context variable will be creating.
This is how I did it:
1) Defines context variables for each database connection parameters e.g. Host, Database, Username etc.
2) Use thse context variables when setting up db connections in any jobs e.g. context.Host, context.Database etc.
3) Create a pre-job routine which load these contexts at runtime. I used tFileInputXML -> tContextLoad.
Hope this is helpful.
Hello nickd_nwea & all,
I've followed the steps given and pointed tFileInputXML -> tContextLoad to load the context from excel file. There is no error occurs but i just wonder how i wants connect to database and retrieve data based on parameter that i've loaded earlier.
Could you plz help me
Hello all, I am facing the same situation as what zara has stated. 1)Is it possible that a database that contains data, can be retrieved through the context variable that I have configured in the tContextLoad? 2) I want to connect the tContextLoad to tMysqlInput. My question is how to use the context variables in the tMysqlInput component settings so that i can connect the tContextLoad to tMysqlInput? Because, I want to retrieve data that i have loaded in the beginning of the process. Any suggestion is very much appreciated.
Hi naim
tContextLoad is used to load value of context variable from database or file. And then, you can use context var in query in tMysqlInput, for example:
tContextLoad
|
tMysqlInput-main--tLogRow
Define the query like:
"select * from tablename where id>"+context.id
Have a look at user component doc and learn tContextLoad.
Hope this will help you!