Twelve Stars TRF
Twelve Stars

Connection reuse in tJava

Hi,
Does anyone know if it is possible to reuse a db connection (issued from tOracleConnection, tSalesforceConnection or other) in a tJava family component, and, if yes, how?
Thank you.

TRF
4 REPLIES
Ten Stars

Re: Connection reuse in tJava

It should be possible.  If you highlight your connection component and switch to code view, you can find where the connection object is created and configured.  It is put on the globalMap for use elsewhere, so if you examine the code of another database component that references the connection, you'll see how the connection retrieved and can mimic the code.

java.sql.Connection conn_tPostgresqlCommit_1 = (java.sql.Connection) globalMap.get("conn_tPostgresqlConnection_2");
if (conn_tPostgresqlCommit_1 != null && !conn_tPostgresqlCommit_1.isClosed()) { ...
Twelve Stars TRF
Twelve Stars

Re: Connection reuse in tJava

Thank you very much @cterenzi, I'll try as soon as possible and let you know.

TRF
Twelve Stars

Re: Connection reuse in tJava

It appears I am a bit late to the party here, but I wrote a mini tutorial on this a while ago.....
https://www.rilhia.com/quicktips/quick-tip-dynamically-change-db-connection

Rilhia Solutions
Twelve Stars TRF
Twelve Stars

Re: Connection reuse in tJava

Thank you @rhall_2_0. Two trails better than one. I'll check that of course and let you know.

TRF