Determining location of relevant tnsnames.ora file - oracle

I installed both the 32 and 64-bit Oracle 11g drivers. I search my PC looking for files with the name "tnsnames.ora" and found 3 in the following locations:
1. C:\Oracle\product\11203_32bit\CLIENT_1\NETWORK\ADMIN
2. C:\Oracle\product\11203_64bit\CLIENT_1\NETWORK\ADMIN
3. C:\Windows\TNS
The existence of the 3rd location of the tnsnames.ora file surprises me.
I have the following Oracle clients installed on my PC:
"C:\Program Files (x86)\Quest Software\Toad for Oracle 11.6\Toad.exe"
"C:\Program Files\Devart\dbForge Studio Express for Oracle\dbforgeoracle.exe"
Based on the location of each program (Program Files (x86) vs. c:\Program Files), This suggests to me that the Toad, a 32 bit program, should use the 32 bit driver and dbForge should use the 64 bit driver.
dbForge seems to use either the tnsnames.ora file in either location #2 or #3. I know this by systematically renaming all but one of the tns files and then checking to see if the connection names read from the file are available when trying to create a new connection from with the app.
However, TOAD seems to only recognize the tnsnames.ora file in location #3 and it did not recognize the tnsnames.ora file in location 2 at all! (Being that it was a 32 bit program, I did not expect it to recognize the tns file in location 2 and that was the case). TO summarize the TOAD test for the sake of hopeful clarity, TOAD only recognized the tns file in location 3.
Other colleagues do not have a tns file in location 3 on their machines. I'm not sure why I do. When I run Toad, it shows the following 2 Home, with the 32 bit Home as being the active one.
OraClient11g_home1 (11.2.0.3)
ORACLE_HOME:C:\app\C39293\product\11.2.0\client_1
ORACLE_HOME_NAME:OraClient11g_home1
ORACLE_HOME_KEY:HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraClient11g_home1
ORACLE_SID:
NLS_LANG:AMERICAN_AMERICA.WE8MSWIN1252
SQLPATH:
LOCAL:
Client DLL:C:\app\C39293\product\11.2.0\client_1\oci.dll
TNSNames.ora:
SQLNet.ora:
LDAP.ora:
Login.sql:
GLogin.sql:
In system PATH:No
Home is valid:No
OraClient11g_home1_32bit (11.2.0.3)
ORACLE_HOME:c:\oracle\product\11203_32bit\CLIENT_1
ORACLE_HOME_NAME:OraClient11g_home1_32bit
ORACLE_HOME_KEY:HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraClient11g_home1_32bit
ORACLE_SID:
NLS_LANG:AMERICAN_AMERICA.WE8MSWIN1252
SQLPATH:c:\oracle\product\11203_32bit\CLIENT_1\dbs
LOCAL:
Client DLL:c:\oracle\product\11203_32bit\CLIENT_1\bin\oci.dll
TNSNames.ora:
SQLNet.ora:
LDAP.ora:
Login.sql:
GLogin.sql:c:\oracle\product\11203_32bit\CLIENT_1\sqlplus\admin\glogin.sql
In system PATH:Yes
Q1: Is OraClient11g_home1 my 64 bit home or do I have two Oracle clients installed?
Q2: Why doesn't 32 bit TOAD use the tns in location #1 instead of only using the one in location #3?
Q3: If I leave on the tns file in location 3, both dbForge and TOAD work but I'd like to know why so I can accurately understand how to move tns info from one machine to another.

According Oracle these locations are searched for tnsnames.ora, resp. sqlnet.ora and ldap.ora:
Oracle Net files in present working directory (PWD/CWD)
TNS_ADMIN defined sessionally or by user-defined script
TNS_ADMIN defined as a global environment variable
TNS_ADMIN defined in the registry
Oracle Net files in %ORACLE_HOME/network|net80\admin (Oracle default location)
However, I am not sure whether each application/driver follows this list. I got this list from Oracle Document 111942.1 referring to Oracle 9i, so it might be outdated.
In Database Net Services Administrator's Guide the order is
TNS_ADMIN defined by environment variable
TNS_ADMIN defined in the registry (if TNS_ADMIN environment variable is not present)
%ORACLE_HOME%/network/admin directory (if TNS_ADMIN environment variable is not present)
I would recommend to define an environment variable for TNS_ADMIN and use only one tnsnames.ora file. In order to be on the safe side, check also your registry values.
If your files are not located in %ORACLE_HOME%\network\admin, I recommend to create a symbolic link for it - just to be on the very safe side, e.g. mklink /d %ORACLE_HOME%\network\admin c:\Oracle\common\settings\admin
Another note, you don't have to "play" with your tnsnames.ora file. With Process Monitor from Microsoft Sysinternals you can monitor each file access, i.e. the filter would be Path contains tnsnames
Update
When I run a test on my machine I get following order:
Environment variable TNS_ADMIN
Registry Key HKEY_CURRENT_USER\SOFTWARE\ORACLE\KEY_{Oracle_Home_Name}\TNS_ADMIN
Registry Key HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_{Oracle_Home_Name}\TNS_ADMIN, resp. HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ORACLE\KEY_{Oracle_Home_Name}\TNS_ADMIN
-> Only if TNS_ADMIN Environment variable is not set.
%ORACLE_HOME%\network\admin
Current directory (which can be different to directory where your application is located)
Folder where your application is located
Update 2
Obviously there is no fix search, it varies for different providers/drivers. Maybe it also depends on the Oracle version.
For example, the Oracle HTTP Server reads TNS_ADMIN setting from opmn.xml config file.
Another example, for ODP.NET Managed Driver (Oracle.ManagedDataAccess) beta version, I found this order at Oracle Managed and TNS Names :
data source alias in the 'dataSources' section under <oracle.manageddataaccess.client> section in the .NET config file (i.e. machine.config, web.config, user.config).
data source alias in the tnsnames.ora file at the location specified by TNS_ADMIN in the .NET config file.
data source alias in the tnsnames.ora file present in the same directory as the .exe.
data source alias in the tnsnames.ora file present at %TNS_ADMIN%
(where %TNS_ADMIN% is an environment variable setting).
data source alias in the tnsnames.ora file present at %ORACLE_HOME%\network\admin
(where %ORACLE_HOME% is an environment variable setting).
In official documentation (12c Release 4 (12.1.0.2.4)) it says:
data source alias in the dataSources section under <oracle.manageddataaccess.client> section in the .NET config file (i.e. machine.config, web.config, user.config).
data source alias in the tnsnames.ora file at the location specified by TNS_ADMIN in the .NET config file. Locations can consist of either absolute or relative directory paths.
data source alias in the tnsnames.ora file present in the same directory as the .exe.
However, based on some tests I made with ODP.NET Managed Driver (4.121.2.0) it takes %ORACLE_HOME%\network\admin and TNS_ADMIN Environment variable into account. Locks like the documentation is not 100% correct.

Just based on your paths you have two installed clients as you suspect (Toad and dbforge are tools, not clients so your terminology is a bit off). One 32-bit, the other 64-bit. It appears that Toad is 32-bit based on its installation path, but execute it and go to Help|Support Bundle. You'll see the top header will be "APPLICATION INFORMATION (32-bit)" or "APPLICATION INFORMATION (64-bit)" just to confirm. Toad 11.6 was the first to introduce a 64-bit version.
Toad will only see the Oracle client that is for the same platform as it. So your 64-bit client is irrelevant for Toad's sake. The C:\Windows\TNS appears to be a folder used for TNS_ADMIN folder given its odd location and the fact that Toad sees it. At command prompt execute SET TNS_ADMIN and see if it reports "TNS_ADMIN=C:\Windows\TNS" If it does, then all Tools should be using that tnsnames.ora. That's a global override if you will that points to the folder containing your net configuration files. If you don't have TNS_ADMIN set as an environment variable then look for it in your Oracle root registry: HKEY_LOCAL_MACHINE\Software\Oracle.
If you use a common set of connections for all of your tools I'd delete all of your tnsnames.ora files. I'd also relocate that C:\Windows\TNS folder to somewhere more appropriate like C:\Oracle\Admin and create your tnsnames.ora, sqlnet.ora, and ldap.ora (if applicable) there. Create a TNS_ADMIN environment variable pointing to that location.

In case you are using Visual Studio v2017 here is tnsNames File:
32 bits installation:
c:\program files (x86)\oracle developer tools for
vs2017\network\admin\tnsnames.ora
64 bits installation:
c:\program files\oracle developer tools for
vs2017\network\admin\tnsnames.ora

Related

Error- pl/sql developer -12154 tns could not resolve the connect identifier specified

Good Morning. I tell you my connection problem with pl / sql Developer.
First, I will indicate my environment:
-SO Windows10 64 bits.
-PLSQL Developer 13 (64 bit)
-Client Oracle 12-64bits.
Now I put the screenshots of my settings.
But finally the connection error message returns
Cause of this issue would be you tried to connect to Oracle, but the service name is either missing from the TNSNAMES.ORA file or is incorrectly defined.
You can try below options:
Make sure that the TNSNAMES.ORA file exists and is in the correct directory.
Make sure that the service name that you are connecting to is included in the TNSNAMES.ORA file and that it is correctly defined.
Make sure that there are no syntax errors in the TNSNAMES.ORA file. For example, if there are unmatched parentheses in the file (ie: open bracket without the corresponding close bracket), the file will be rendered unusable.
Check if tnsping works. Open command window type tnsping SERVICE_NAME. Here SERVICE_NAME is the oracle database you want to connect to and it must already exist in tnsnames.ora file where your client product is installed.
If tnsping works and still PL/SQL Developer complains about ORA-12154 then check where PL/SQL Developer program is installed. If it is located in an address which contains brackets this is the problem. So uninstall and reinstall it in a location where location address doesn't contain brackets.
set Environment Variables: ORACLE_BASE, ORACLE_HOME, ORACLE_SID
I hope this works with the above options

Can't find SQLPATH registry entry Oracle 11.2 Express

I'm trying to start working through Tom Kyte's book, "Expert Oracle Database Architecture" and have run into a snag. Tom recommends creating a custom login.sql script and briefly mentions setting the SQLPATH environment variable.
I've been following the instructions found here: http://docs.oracle.com/cd/B28359_01/server.111/b31189/ch2.htm#i1133354
I've searched for the SQLPATH and HOME0 keys, and for the ORACLE_HOME\DBS value, but it doesn't seem to exist in the Registry. I have Oracle 11.2 Express, Windows 8, and my Oracle instance name is the default, XE. In the Registry, I see
HKEY_LOCAL_MACHINE
SOFTWARE
ORACLE
KEY_XE
...
ORACLE_HOME (value: C:\oraclexe\app\oracle\product\11.2.0\server)
ORACLE_HOME_KEY
ORACLE_HOME_NAME
...
ODE
...
OLEDB
...
ODP.NET
2.112.2.0\
4.112.2.0\
OracleMTSRecoveryService
Protid_0
Setup
All Versions
1\
Current Version\
Is it possible that the SQLPATH variable is no longer created by default, and that I need to just create a new one? If so, exactly where should it exist? If not, then what?
SQLPATH is a Windows system-or user environment variable not found under KEY_XE.
You can set the SQLPATH like this: Right-click on "Computer" -> Properties -> Advanced Settings - Environment
me#XE>host set SQLPATH
SQLPATH=c:\projects\oracle\sqlplus
-- verification
me#XE>#[%SQLPATH%]
SP2-0310: unable to open files "[c:\projects\oracle\sqlplus].sql
Bjarte

Configure Oracle Sqlldr on Windows 7

I'm having a hard time configuring Sqlldr with Windows 7.
The Oracle client was previously installed by our support team.
There were no registry settings, but Sqlplus, Toad, and Plsql Developer all worked.
I copied Sqlldr from another server and put it in the bin directory of my localhost.
In my environmental variables, I defined Oracle_Home, LD_LIBARY_PATH, and ORACLE_SID.
Now, whether I call the program by the command line or ETL tool, I get:
ERROR>Message 2100 not found;
No message file for product=RDBMS, facility=ULMessage 2100 not found;
No message file for product=RDBMS, facility=UL
What gives?
P.s. It's not a path issue because I can run sqlldr on the command line (with the error)
Did you copy all the sqldr dependent files? You can't just copy over the binary only. The oracle sqlldr has dependencies to msg files it needs. i would suggest getting the client installer for the oracle client that is installed on your win7 box and have it install the sqlldr component that way you have all the dependent files and libraries it needs. Manually copying the sqlldr from aonther machine is not really supported and not advised.

ora-12154 could not resolve... with oracle instant client

Here are the details:
I installed the oracle instant client 11.2.0.2.0 from the OTN download page on a windows 7 64 bit vm (vmware).
I am trying to to connect to a remote oracle database, and I can successfully connect with one program using TNS, but not with SQL*Plus and other applications.
Trying to connect with SQL*Plus, using schema#servicename, password, etc, gives the above error.
To connect via SQL Developer, normally I would use the basic connection info and not rely on tnsnames, but trying a normal connection gives me: io error: unknown host specified. SQL Developer can successfully connect and query database if i use the TNS protocol.
Trying from other programs gives me the same error I got with SQL*Plus. Same when trying with the service name from tnsnames.
This is obviously quite frustrating for it to work one way and not the other. I followed all the normal instructions for using the instant client, the directory with instantclient has been addded to the PATH, a TNS_ADMIN entry has also been created, with the directory to the tnsnames.ora file
Well, on a whim, I went to changing everything in my setup to match an windows 2003 server that i had setup with instant client before. The main changes were putting the instant client in a folder at the root of the drive (not program files/oracle/etc), but c:/oracle, i know ive seen other posts saying that oracle was particular about characters in the directory path, maybe spaces are a no-no too?
I also add a bunch more environmental variables, anythign that was on the other machine, ORACLE_HOME (to root of instance), SQL_PATH (same), and added the root of the directory to the PATH system variable, not just the folder with the instantclient files. Anyways, I'm happy its working, anyone one of these changes could have been it though-
You may use ProcessMonitor and look at what your sqlplus process is doing. In my case TNS_ADMIN was correctly defined but, by mistake, my tnsnames.ora and sqlnet.ora had a stupid ".txt" extension, added by default by notepad when I created those files. And because "Windows Explorer" has the "Hide extensions for known file types" option set by default, the naming error wasn't obvious at all.
I installed the 12.1 instant client. For me, the problem was solved by creating \network\admin\tnsnames.ora file. Here's the PowerShell I used:
$source = "C:\Users\USER1\Desktop\tnsnames.ora"
$target = "C:\oracle\product\12.1.0\client_1\network\admin"
mkdir $target
copy-item $source $target

Oracle tns listener error

I've just installed Oracle 10g When I try to connect to oracle db i get an error:
could not start OracleOraHome92TNSListener
when i got to services and try to start it, it says that the file doesnt exist. the service file is C:\oracle\ora92\BIN\TNSLSNR (TNSLSNR is a file not a directory)
C:\oracle\ora92\BIN\TNSLSNR doesn't exist on my machine at all. do you know how to get it?
Could not start the Oracle Ora92 Listener service on Local Computer.Error 2: The system cannot find the file specified
Here's a couple of issues I see. You say you installed 10g but the error is a 9.2 error. It could be that your computer already had an Oracle 9i on it that was mis-configured or uninstalled and that is leading to the error.
You need to check your disk and find the ORACLE_HOME (directory) where Oracle 10g was installed. Once you find that you can adjust the PATH and ORACLE_HOME and TNS_ADMIN environment variables to point to the right place. This should allow you to start the database and the listener.
If you need to install the Oracle Client for 10g then this information below will be helpful as well.
The Oracle client can be installed separately. Just go to this address, download the client and unzip it into a subdirectory and then run the Oracle Universal Installer by running setup.exe from the directory.
Oracle Downloads Page

Resources