How to pass a database connection to a routine?

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
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.

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Why Companies Move to the Cloud: 7 Success Stories

Learn how and why companies are moving to the Cloud

Read Now