One Star

How can I dynamically change the Connection Type of tOracleConnection

Hi
I need to be able to dynamically switch between the connection types "Oracle SID" and "Oracle service name" of an tOracleConnection.
I've tried putting a tJava before the tOracleConnection but I can't find the correct syntax to get the tOracleConnection and modify the connection type property.
Is what I want to do possible and if so how ?
Kind Regards
Paul
3 REPLIES
Fifteen Stars

Re: How can I dynamically change the Connection Type of tOracleConnection

This is going to require a connection component for each type, some logic you can rely on to pick the connection you want and some Java code to replace the connection component that is used in all of your db components.
Essentially, the way to do this would be (and I have not tried this) to create all of your db components so that they use an Existing Connection. Then create some logic which will allow you to decide what type of connection you need. Use RunIF links to initiate that connection component. Then replace the connection component that is used as the "Existing Connection" in all of your db components, by replacing it in it's globalMap location. For an Oracle connection called "tOracleConnection_1" the connection is stored in a hashmap called "globalMap" as below....
globalMap.put("conn_tOracleConnection_1",conn_tOracleConnection_1);

You need to find the name of the connection you wish to use to supersede the connection you have used in your db components and do something like below (assuming your superseding connection is "tOracleConnection_2"....
globalMap.put("conn_tOracleConnection_1",conn_tOracleConnection_2);

Notice I left the the key name as "conn_tOracleConnection_1" and changed the object. You may need to first retrieve the object for "tOracleConnection_2". In order to do that use the code below....
java.sql.Connection conn_tOracleConnection_2 = (java.sql.Connection)globalMap.get("conn_tOracleConnection_2");

This will require a bit of Java knowledge to debug and play around until you get it right. 
As I said, I have not tried this and would doubt that many people have. But if I were tasked with doing this, this is exactly how I would attempt it. I'd be interested to hear if you have any success with it.
Rilhia Solutions
One Star

Re: How can I dynamically change the Connection Type of tOracleConnection

Hi
Thanks for your answer, it works as you described.
2 connection objects, some if run logic to go to the required connection object (with SID or with Service) and then a tJava to copy the connection2 into the connection1 as connection1 is defined for all the db components.
Best Regards
Paul
Fifteen Stars

Re: How can I dynamically change the Connection Type of tOracleConnection

Glad it works. I might build a component around this idea to remove the need for the coding.
Rilhia Solutions