Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
TRF
Champion II
Champion II

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.
Labels (4)
4 Replies
cterenzi
Specialist
Specialist

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()) { ...
TRF
Champion II
Champion II
Author

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

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

TRF
Champion II
Champion II
Author

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