Normal
0
false
false
false
EN-GB
X-NONE
X-NONE
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:”Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:””;
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:”Calibri”,”sans-serif”;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}
[Source: http://geekswithblogs.net/EltonStoneman]
The typical approach for connecting to Oracle data sources using ODP.NET is to use a named source in the connection string and rely on the name being resolved through SQLNAMES.ORA and TNSNAMES.ORA:
app.config:
<connectionStrings>
<add name=“XYZ“ connectionString=“Data Source=XYZ.WORLD;User ID=xyz;Password=xyz;“/>
</connectionStrings>
TNSNAMES.ORA:
XYZ.WORLD =
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = off)
(FAILOVER = on)
(ADDRESS_LIST =
(LOAD_BALANCE = on)
(FAILOVER = on)
(ADDRESS = (PROTOCOL = TCP)(HOST = XYZ1-1.internal.xyz.org.uk)(PORT = 1522))
(ADDRESS = (PROTOCOL = TCP)(HOST = XYZ1-2.internal.xyz.org.uk)(PORT = 1522))
)
(ADDRESS_LIST =
(LOAD_BALANCE = on)
(FAILOVER = on)
(ADDRESS = (PROTOCOL = TCP)(HOST = XYZ2-1.internal.xyz.org.uk)(PORT = 1522))
(ADDRESS = (PROTOCOL = TCP)(HOST = XYZ2-2.internal.xyz.org.uk)(PORT = 1522))
)
)
(CONNECT_DATA =
(SERVICE_NAME = XYZ)
(FAILOVER_MODE =
(TYPE = select)
(METHOD = basic)
(RETRIES = 16)
(DELAY = 1)
)
)
)
This is fine until you upgrade your Oracle client, or have multiple instances – if the wrong TNSNAMES gets picked up you’ll get error ORA-12514: TNS:could not resolve the connect identifier specified, and it can be fiddly to track down.
A neater way is to put the whole set of service details in the connection string, avoid the named identifier and circumvent TNSNAMES.ORA altogether:
<connectionStrings>
<add name=“XYZ“ connectionString=“Data Source=(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = off)
(FAILOVER = on)
(ADDRESS_LIST =
(LOAD_BALANCE = on)
(FAILOVER = on)
(ADDRESS = (PROTOCOL = TCP)(HOST = XYZ1-1.internal.xyz.org.uk)(PORT = 1522))
(ADDRESS = (PROTOCOL = TCP)(HOST = XYZ1-2.internal.xyz.org.uk)(PORT = 1522))
)
(ADDRESS_LIST =
(LOAD_BALANCE = on)
(FAILOVER = on)
(ADDRESS = (PROTOCOL = TCP)(HOST = XYZ2-1.internal.xyz.org.uk)(PORT = 1522))
(ADDRESS = (PROTOCOL = TCP)(HOST = XYZ2-1.internal.xyz.org.uk)(PORT = 1522))
)
)
(CONNECT_DATA =
(SERVICE_NAME = UVASA)
(FAILOVER_MODE =
(TYPE = select)
(METHOD = basic)
(RETRIES = 16)
(DELAY = 1)
)
)
);User ID=xyz;Password=xyz;“/>
</connectionStrings>
Service details contain the whole of the TNSNAMES entry following the identifier (i.e. from DESCRIPTION= onwards), and can span multiple lines in the config file.
Incidentally, if you’re not using ODP.NET in favour of the Microsoft’s framework Oracle provider, System.Data.OracleClient, consider migrating as it will be deprecated from .NET 4.0.