This discussion is archived
9 Replies Latest reply: Aug 16, 2013 2:47 PM by Alex_Keh - Oracle_Product_Manager RSS

Oracle Managed and TNS Names

Invincible Newbie
Currently Being Moderated
Hi Alex,
First great session yesterday, it's look like very promising, what I missed was a performance comparison between Managed and Unmanaged provider.

For tnsnames.ora file, as I understood the paths where the managed client is looking for tnsnames.ora are in follow order:
1. Working directory.
2. Path defined in app.config, web.config, machine.config
There should be two more locations:
3: Path defined by TNS_ADMIN env. variable
4 ORACLE_HOME/network/admin path

If you don't want to support TNS_ADMIN and ORACLE_HOME, there should be a public class for parsing tnsnames.ora. Then if I want to use ORACLE_HOME I can find myself the tnsnames.ora file and parse it using this api.
  • 1. Re: Oracle Managed and TNS Names
    Tridus Journeyer
    Currently Being Moderated
    Invincible wrote:
    Hi Alex,
    First great session yesterday, it's look like very promising, what I missed was a performance comparison between Managed and Unmanaged provider.
    It was mentioned briefly in the chat Q&A part of GoToMeeting, they said the performance is pretty similar. Maybe a bit faster due to fewer context switches.
  • 2. Re: Oracle Managed and TNS Names
    Invincible Newbie
    Currently Being Moderated
    Tridus wrote:

    It was mentioned briefly in the chat Q&A part of GoToMeeting, they said the performance is pretty similar. Maybe a bit faster due to fewer context switches.
    Yes I know that but Charts and Numbers are better :)
    Maybe some tests like select 10 000 rows for X and Y ms
  • 3. Re: Oracle Managed and TNS Names
    Alex_Keh - Oracle_Product_Manager Expert
    Currently Being Moderated
    TNS_ADMIN option will be available. You can only set it in the .NET config file, not on the OS itself. ODP.NET will look for a valid data source in the following precedence order:

    1. TNS alias in the .NET config files (app/web/machine)
    2. TNS alias in the tnsnames.ora at the location specified by 'TNS_ADMIN' in the .NET config files.
    3. TNS alias in the tnsnames.ora file present in the same directory as that of the application's working directory.

    There is no ORACLE_HOME, which means there is no network/admin directory location for managed ODP.NET.

    With respect to performance, it will probably be similar between the two providers. There is less context switching between managed/unmanaged with the managed provider. However, the unmanaged provider is compiled, which is always faster than managed code. There may be certain scenarios where one provider is much faster than the other, but I can't make a definitive statement that one provider will be significantly and consistently faster than the other.

    The takeaway point is that performance should not be a key consideration in using the managed provider. Look at your functionality requirements. In fact, some functionality specifically addresses performance, such as client result caching and TimesTen. These two features won't initially be available with the managed provider. Those who will benefit most from managed provider are not developers per se, but IT administrators responsible for deploying ODP.NET and packaging ODP.NET and maintaining multiple versions side by side.
  • 4. Re: Oracle Managed and TNS Names
    Invincible Newbie
    Currently Being Moderated
    Hi, Alex
    Today I take a look in ManagedProvider code and actually GetOraFilePath method looks for ORACLE_HOME\network\admin :)
  • 5. Re: Oracle Managed and TNS Names
    Alex_Keh - Oracle_Product_Manager Expert
    Currently Being Moderated
    Yes, we made some changes by the time we released the beta. The order of precedence for resolving network naming in the beta is:

    1. data source alias in the 'dataSources' section under <oracle.manageddataaccess.client> section in the .NET config file.
    2. data source alias in the tnsnames.ora file at the location specified by 'TNS_ADMIN' in the .NET config file.
    3. data source alias in the tnsnames.ora file present in the same directory as the .exe.
    4. data source alias in the tnsnames.ora file present at %TNS_ADMIN% (where %TNS_ADMIN% is an environment variable setting).
    5. data source alias in the tnsnames.ora file present at %ORACLE_HOME%\network\admin (where %ORACLE_HOME% is an environment variable setting).
  • 6. Re: Oracle Managed and TNS Names
    brownph Newbie
    Currently Being Moderated

    Did the precedence order change with the release version?

     

    I have the following in my app.config

     

    <oracle.manageddataaccess.client>

    <version number="*">

    <settings>

         <setting name="TNS_ADMIN" value="C:\Code\OlbElerts\OTSElerts2010\OTSElerts\bin\Debug"/>

    </settings>

    <version>

    <oracle.manageddataaccess.client>

     

     

    But, when I run my code and get a DataSourceEnum from the OracleFactory, it's referencing a tnsnames in an entirely different directory.

     

  • 7. Re: Oracle Managed and TNS Names
    Alex_Keh - Oracle_Product_Manager Expert
    Currently Being Moderated

    The order didn't change in production. We just eliminated the last two. The new order is below.

     

    I believe your problem is that you are using the <settings> tag when you should be using the <dataSources> tag.

     

    ------------

     

    The following precedence order is followed to resolve the data source alias specified in the Data Source attribute in the connection string.

    1. data source alias in the dataSources section under <oracle.manageddataaccess.client> section in the .NET config file.
    2. data source alias in the tnsnames.ora file at the location specified by TNS_ADMIN in the .NET config file.
    3. data source alias in the tnsnames.ora file present in the same directory as the .exe.
  • 8. Re: Oracle Managed and TNS Names
    brownph Newbie
    Currently Being Moderated

    I double-checked the current documentation and it still seems like the TNS_ADMIN is supposed to be within the <settings> tag. 

    The other thing is that, the tnsnames.ora that the OracleClientFactory appears to be reading is definitely not in the same directory as the exe. I modified the tnsnames.ora in my %ORACLE_HOME%/network/admin directory with a unique alias and that is what's being read and returned when I GetDataSources.

     

    I eventually, completely renamed my %ORACLE_HOME%/network/admin/tnsnames.ora, and then it finally started readying the tnsnames in the executable directory.  So something about the precedence order may not be documented correctly, especially if a full client is installed on the development machine.

  • 9. Re: Oracle Managed and TNS Names
    Alex_Keh - Oracle_Product_Manager Expert
    Currently Being Moderated

    You're right about the <settings> tag. I was thinking of the alias and descriptor setting, which is under the <dataSources> area.

     

    Back to your original issue. The precedence order is correct. What happened was that your ODP.NET instance used the TNS_ADMIN defined in your machine.config. And that TNS_ADMIN pointed to the %ORACLE_HOME%/network/admin directory where the existing tnsnames.ora was found. Because anything in your .config files have precedence, the TNS file in your executable directory was never checked.

     

    This was a new ODAC 12c install feature whereby the Oracle Universal installer copies over an existing tnsnames.ora to your new Home, then also references it in the machine.config. If you open your machine.config, you'll see the TNS_ADMIN entry. If you delete it, you can continue using the TNS file in your executable directory.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points