[resolved] Close the database connection on Job Error/fail

One Star

[resolved] Close the database connection on Job Error/fail

Hi All,
How to close the database connection in the Talend job on job erros. In our job we open a database connection with tMSSqlConnection and at the end of the job we close it. But if some thing goes wrong in the middle of the job, how to close the database connection?
Do talend job will close automatically on error/expcetion ?
I can check on every component on component error and close the connection, but just wondering is there any easy way to close all connections on job exception/error.
Thanks
Ramesh

Accepted Solutions
Moderator

Re: [resolved] Close the database connection on Job Error/fail

Hi,
And one more question is the tPostJob runs even if we check the checkbox (die on error) on any component?

tPostJob and tPreJob can run even if checkout "die on error" on any component, because they are enforcement and can run under any situation in job .
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

All Replies
Seventeen Stars

Re: [resolved] Close the database connection on Job Error/fail

You can use the tPost component to do that.
tPost will always executed even if the job fails.
tPost -> OnComponentOK -> tMSSqlClose
Moderator

Re: [resolved] Close the database connection on Job Error/fail

Hi,
Add the reference tPostjob and How to use the tPrejob and tPostjob components into forum. Hope it will be useful.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: [resolved] Close the database connection on Job Error/fail

Thanks,
Yes, I am using the tPostJob to close the database connection, now it cleared my doubt that tPostJob will run even on job fail also.
And one more question is the tPostJob runs even if we check the checkbox (die on error) on any component?
Thanks
Ramesh
Moderator

Re: [resolved] Close the database connection on Job Error/fail

Hi,
And one more question is the tPostJob runs even if we check the checkbox (die on error) on any component?

tPostJob and tPreJob can run even if checkout "die on error" on any component, because they are enforcement and can run under any situation in job .
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: [resolved] Close the database connection on Job Error/fail

Thank you verymuch Sabrina.
Ramesh
Moderator

Re: [resolved] Close the database connection on Job Error/fail

Hi,
You are welcome, feel free post your issue on forum.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: [resolved] Close the database connection on Job Error/fail

May I ask. what to put on code in dynamic settings for toracleclose component.
Thanks,
duffney
Moderator

Re: [resolved] Close the database connection on Job Error/fail

Hi duffney,
Would you mind giving us more information about your issue? You want to use dynamic setting(Component List) in component toracleClose?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: [resolved] Close the database connection on Job Error/fail

Good morning,
can you please explain me the best practices for using tMSSQLConnection and tMSSQLCommit in ESB jobs, starting with tESBProviderRequest? I have the following doubts related to the topic above:
tPostjob does not work in ESB jobs, it is never triggered. Neither, OnSubjobOk/Error is triggered from tESBProviderRequest. Instead, we use tLogCatcher to catch exceptions and we put tESBProviderFault there. So should we also close the connection there in case of failure? Will the connection remain open forever if we dont close it in this section, or will it recycle then the job is invoked by another request (so that it remains registered within the TalendESBJobFactory? If it remains open, what happends when the underlying network connection gets broken, will it reconnect?
We use the following structure of the web services:
tMSSQLConnection -- onSubJobOK --> tESBProviderRequest --> my logic --> tESBProviderResponse
tLogCatcher --> tXMLMap --> tESBProviderFault or Response (depending on situation)
The same for tRouteInput jobs.
Thanks a lot. Michal
P.S. I know this is a Talend DI section, but the question seems to be relevant to the topic to me :-)