One Star

How to pass a database connection to a routine?

Hi,
I would like to make a java routine that takes a database connection as a parameter.
How can I do that?
Sebastien
4 REPLIES
Community Manager

Re: How to pass a database connection to a routine?

Hi Sebastien
Use a txxxxConnection such as tMysqlConenction to create a DB connection in the job, and the pass this connection as a paramater to the routine like this:
YourRoutineName.methodName((java.sql.Connection) globalMap
.get("conn_tMysqlConnection_1"))

The routine is defined as below, for example:
  public static void methodName(java.sql.Connection parameterName) {
java.sql.Connection conn=parameterName;
...
}

Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Five Stars

Re: How to pass a database connection to a routine?

Hello,
I would like to create a routine which would call a database stored function. Then I would use the routine in a tMap.
I have written the routine but the performance is very poor as a jdbc database connection is created for every call to the routine. I am aware about connection pooling in J2EE  but do not know how to achieve that in Talend
What would be the best strategy to speed up the stored procedure call ?
Thanks for your ideas.
Lalaina
Seventeen Stars

Re: How to pass a database connection to a routine?

Hi Irako,
it is not necessary to create a Connection for every record. This is a problem of your job design and not an issue of the solution shong provided. You could post your job design as screenshot, so we could make some suggestions. 
Moderator

Re: How to pass a database connection to a routine?

Hi Lalaina,
Would you mind attaching your job design screenshots into forum?
Feel free to let us know if there is any problem to upload screenshot.
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.