Getting sqlplus to read tnsnames.ora

I have installed the instant client (version 11_1) on an Ubuntu box (9.04)
I have a tnsnames.ora file I would like to use with sqlplus.
What do I need to do to configure to get sqlplus to use my tnsnames.ora file?
When I strace the sqlplus process, I see that it tries accessing tnsnav.ora (in several locations)
but never tnsnames.ora. I have placed a copy of the tnsnames.ora file in /etc, but sqlplus is not
checking for a tnsnames.ora file in any directory.
I've tried putting:
network.directory_path TNSNAMES
in my ~/.sqlnet.ora file. Sqlplus is reading that file, but that had no effect.
Thanks!

Hi,
The default installation of tnsnames.ora is in:
${ORACLE_HOME}/network/adminAn example of an entrie:
XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = <host_name or IP>)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = <SID>)
  )Also you should check [Oracle® Database Installation Guide 11g Release 1 (11.1) for Linux|http://download.oracle.com/docs/cd/B28359_01/install.111/b32002/toc.htm]
Regards,

Similar Messages

  • Urgent : Is there any c++ parsers available for reading tnsnames.ora

    I have to parse the tnsnames.ora and get the connection string , host name , instance name , port etc .. and store it in my local memory structure . Is there any c++ parsers available , which parses and gives the desired output or do i have write my own parser .

    You're right...the database connections work fine if I define them manually rather than reading them from the tnsnames.ora file.
    I was hoping to have many users running SQL Developer so using the tnsnames.ora file might save people's time and reduce the number of database connection-related support calls.
    If worse comes to worse, I can create an XML file to define the database connections. The only drawback to this is that we have an automated procedure to update people's tnsnames.ora whereas there is currently no way to keep the XML file up-to-date.

  • SQL Developer not only reading tnsnames.ora

    Hello,
    I have found a very odd behaviour in SQL Developer 1.2 (running on Windows 2000):
    I have set TNS_ADMIN to point to a directory on a network drive residing on a Linux host. In this directory there were many backup files of tnsnames.ora created over time whose names followed the pattern tnsnames.ora.<timestamp> or tnsnames.bak or something similar. In SQL Developer in the "New database connection" dialog many TNS-entries showed up multiple times in the "Network alias" listbox. Only after removing all those backup files from the directory the behaviour of SQL Developer was correct and every entry only showed up once. I also found out that even when I moved the backup files to a new directory "tnsnames.bak" under the directory which TNS_ADMIN points to the entries showed up multiple times. After I renamed this directory to bak.tnsnames the behaviour was again correct. In my opinion SQL Developer should only read the file called tnsnames.ora and ignore all other files or directories with similar names.
    Kind regards,
    Christof Breker

    Various users reported this before.
    Maybe others use multiple files, but at least there should be the option to read just this one.
    Regards,
    Kristof

  • 1.2.0 reads TNSNAMES.ORA file multiple times and duplicates values in Alias

    Since upgrading to 1.2.0.29.98 (clean install on Win XP SP 2), I have noticed that SQL Developer appears to be reading the TNSNAMES.ORA file multiple times. This results in the Network Alias pop-list on the TNS connection type to have duplicate values, although the number of duplicates for each entry varies widely - from four for the least that I saw and 252 for the most (assuming I counted that right :) ). We have approximately 270 entries in our TNSNAMES.ORA and the first entry in the file appears in the Network Alias list four times and the last entry in the file appears in the list 48 times.
    To be honest, I switched to Basic JDBC connections with 1.1 and only noticed the problem because of some network performance issues - I thought that SQL Developer had hung and I switched on the debugging and could see that it was looping through the TNSNAMES.ORA file. Now that the network performance issues have been resolved, it still takes a little while to open the new connection window, but it is liveable, so I don't know whether the problem is 1.2 specific or not.

    Sue,
    I assume from a bit of testing, that "each tns file on the system" means each file in the TNS_ADMIN location that starts with TNSNAMES.ORA.
    I set my TNS_ADMIN to a local location and copied the current TNSNAMES.ORA from the network location (and chopped it down to a handful of entries). When I restarted SQL Developer I only had a single copy of each alias. If I copied TNSNAMES.ORA to "Copy of TNSNAMES.ORA" I still only had a single copy of each alias. If I copied TNSNAMES.ORA to TNSNAMES.ORA.TXT I then had two copies of each alias.
    Unfortunately, I don't have any say in the maintenance of the network TNS_ADMIN location and it has almost 200 backup copies of the tns file, typically named TNSNAMES.ORA.YYYYMMDD.
    My TNS_ADMIN setting is done as a Windows environment variable. I do not have any TNS_ADMIN setting in my registry.

  • Tnsping can't read tnsnames.ora  TNS-12533: TNS:illegal ADDRESS parameters

    Here's my tnsnames.ora. tnsping thinks it's illegal:
    acsplan =
    (DESCRIPTION=ACSPLAN
    (ADDRESS_LIST =
              (ADDRESS=(PROTOCOL=tcp)(HOST=10.101.205.166)(PORT=1521))
    (CONNECT_DATA=(SID=ACSPLAN))
    Why does tnsping think this is illegal?
    Thanks.
    Dean

    Dean Schulze wrote:
    Here's my tnsnames.ora. tnsping thinks it's illegal:
    acsplan =
    (DESCRIPTION=ACSPLAN
    (ADDRESS_LIST =
              (ADDRESS=(PROTOCOL=tcp)(HOST=10.101.205.166)(PORT=1521))
    (CONNECT_DATA=(SID=ACSPLAN))
    Why does tnsping think this is illegal?Does this work?
    acsplan  =
       (DESCRIPTION=
         (ADDRESS_LIST =
              (ADDRESS=(PROTOCOL=tcp)(HOST=10.101.205.166)(PORT=1521))
         (CONNECT_DATA=(SID=ACSPLAN))
       )

  • Cannot find tnsnames.ora error message

    We are using oracle 10.2.0.1 via Toad. I get a cannot find tnsnames.ora file error message and see only a tnsnames.ora file in the sample file under the c:\ORACLE\product\10.2.0.1\NETWORK\ADMIN\ directory.
    Do I need to create this file, and if so how do I do this?
    Thanks in advance for your help
    regards,
    user12943453

    Do I need to use the TNSNames Editor? No need for tnsnames.ora or SQL*net to access local DB
    Can I just use direct connect and the sqlnet editor?YES!

  • How to use ODBC SQLDriverConnect() without using tnsnames.ora file

    I have an ODBC application that connects to an Oracle 10g database. Currently, my SQLDriverConnect() function call uses the following connection string:
    DRIVER={Oracle in OraClient10g_home1}; DBQ=MyDB.world; DBA=W; UID=foo; PWD=bar
    This requires an entry in the tnsnames.ora file that looks like this:
    MyDB.world =
    (DESCRIPTION = (ADDRESS_LIST =
    (ADDRESS =
    (PROTOCOL = TCP)(Host = server1.intel.com)(Port = 1521)
    (ADDRESS =
    (PROTOCOL = TCP)(Host = server2.intel.com)(Port = 1521)
    (ADDRESS =
    (PROTOCOL = TCP)(Host = server3.intel.com)(Port = 1521)
    (ADDRESS =
    (PROTOCOL = TCP)(Host = server4.intel.com)(Port = 1521)
    (LOAD_BALANCE = yes)
    (CONNECT_DATA = (SERVER = DEDICATED)
    (SERVICE_NAME = MY_SRVC))
    However, I would really like to be able to connect using ODBC without having to create that entry in the tnsnames.ora file. I have tried to substitute the DBQ=MyDB.world with the entire (DESCRIPTION=..... string from the original tnsnames.ora file, but it returns the error:
    ORA-12154: TNS: Could not resolve the connect identifier specified.
    I have heard others are able to use sqlplus with no tnsnames.ora file and the do specify the entire (DESCRIPTION=.... string on the sqlplus connection string, but is this possible to do using the ODBC SQLDriverConnect() function? If so, do I need to use a different keyword/value pair other than DBQ=?
    Any help on this would be greatly appreciated.
    Thank you.

    How would that work in a load balanced configuration? Take a closer look at the tnsnames.ora example I included in my original post. I have 4 ADDRESS= sections to denote 4 servers that are part of the load balanced environment.
    Also, I'm not familiar with that syntax, I need to use the syntax supported by the SQLDriverConnect() API function, which looks like this:
    DRIVER={Oracle in OraClient10g_home1}; DBQ=MyDB.world; DBA=W; UID=foo; PWD=bar
    I don't know as SQLDriverConnect() would accept an alternative syntax. But the more important issue here is the ability to specify those 4 servers in the load balanced configuration as indicated by that tnsnames.ora entry.

  • Connecting to Oracle database in Java using TNSNAMES.ora

    I have a program that can connect to both MSSQL and Oracle databases. It works fine when a user has defined an odbc connection, however if the user only has a tnsnames.ora, I don't know how to code the program in Java to connect to the database. I can't hard-code the server name because I don't know the database up front - I need to be able to read tnsnames.ora to get the information instead. How can I get this information? So far, the object OracleDataSource seems to be getting me the closest, however I am still failing to connect.

    In 10.2, JDBC-Thin supports TNSNAMES entries lookup in tnsnames.ora, resulting in a much simplified and driver type independent Oracle Net descriptor. You must set the system property oracle.net.tns_admin to the directory that contains your tnsnames.ora file.
    See the Oracle JDBC 10.2 doc.
    Here is a code fragment from my book (see my blog below)
    java -Doracle.net.tns_admin=$ORACLE_HOME/network/admin
    or:
    System.setProperty("oracle.net.tns_admin", "c:\oracle\net\admin");
    OracleDataSource ods = new OracleDataSource();
    ods.setTNSEntryName("tns_alias");
    ods.setUser("scott");
    ods.setPassword("tiger");
    ods.setDriverType("thin");
    Connection conn = ods.getConnection();
    Kuassi - blog http://db360.blogspot.com/

  • DBA studio: Error add/connect database "Failed to parse tnsnames.ora file"

    I have Oracle (version 8.1.7) installed in my XP machine and when I try to (having chosen "Launch DBA Studio standalone") to open a connection I get:
    "Failed to parse tnsnames.ora file
    ERROR: 100 -- NLNV-NLNV String Format Error".
    Also got this when I tried to manually add a database to a tree.
    I can access the databases listed in my tnsnames.ora using SQL Plus with no error.
    This is my tnsnames.ora.
    # TNSNAMES.ORA Network Configuration File: C:\oracle\ora81\network\admin\tnsnames.ora
    # Generated by Oracle configuration tools.
    INST1_HTTP.xx.yy.GE.COM =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = MyMachine3)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = SHARED)
    (SERVICE_NAME = buch3ora)
    (PRESENTATION = http://admin)
    EXTPROC_CONNECTION_DATA.xx.yy.GE.COM =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    (CONNECT_DATA =
    (SID = PLSExtProc)
    (PRESENTATION = RO)
    MyOra3.xx.yy.GE.COM =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = MyMachine3)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = ora3)
    OORCL.xx.yy.GE.COM =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 3.4.55.66)(PORT = 1521))
    (CONNECT_DATA = (SERVICE_NAME = oorcl))
    Does anybody have any idea what is wrong? Thanks a lot. Changsong

    Just found out this IS a string error in my Tnsname.ora. What i did is deleting all the entries in my tnsname.ora, and start adding each one back. I found one particular entry is responsible for the error. This is the old text
    serv32.xxx.ge.com =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (COMMUNITY = TCP)(PROTOCOL = TCP)(HOST = sevr32.xxy.ge.com)(PORT = 1521))
    (CONNECT_DATA = (SID = atmo32))
    just looking by itself I can't see anything wrong. I just formatted it a little, making it looked like the other one that is working
    serv32.xxx.ge.com =(DESCRIPTION =
         (ADDRESS_LIST =
         (ADDRESS =
         (COMMUNITY = TCP)
         (PROTOCOL = TCP)
         (HOST = sevr32.xxy.ge.com)
         (PORT = 1521)))
         (CONNECT_DATA=
         (SID = atmo32)))
    and now it works fine. I Really can't tell the difference, except that some words were moved to the other line. What puzzled me is that the same old tnsname.ora worked in almost all the other circumstances, like sql plus, and other database enginee. But it is just not good enough for dba studio?
    I admit I probably should have used the network utility to add a connection to avoid this type of format error.
    Anyhow, I'm glad it is solved. by the way, the symjct.dll mentioned in the previous post should be symcjit.dll. I guess he mispelled the name. I renamed it to symcjit_old.dll and now the java error was gone. So that is another gain from this post. Thanks Joel for all the information.

  • About Tnsnames.ora

    Hi where can i get more info about 'Tnsnames.ora'.
    Thanks
    Venkat

    If you want in-depth info, do a search for the Net8 ADministrator's Guide from the OTN main page.
    Justin

  • Getting host, port from the tnsnames.ora with the service name

    Hi.
    I think that I asked a similar question yesterday. I want to ask if there is a way to get host and port from the tnsnames.org with a given service name. Somebody answered it for getting SID in the sqlplus. so I tried it in a similar way, but it didn't work.
    I have a service name, but I don't know how to get host and port. I know that I can parse the tnsnames.ora file to get it, but if possible, I want to use the more official and safe way.
    I'd appreciated if somebody knows it.

    caesarkim wrote:
    Hi.
    I think that I asked a similar question yesterday. I want to ask if there is a way to get host and port from the tnsnames.org with a given service name. Somebody answered it for getting SID in the sqlplus. so I tried it in a similar way, but it didn't work.
    I have a service name, but I don't know how to get host and port. I know that I can parse the tnsnames.ora file to get it, but if possible, I want to use the more official and safe way.
    I'd appreciated if somebody knows it.Oracle RDBMS does not require SQL*Net to operate.
    Oracle RDBMS does NOT now or care about content of any tnsnames.ora file.
    Realize that each (remote) user can have their own personalized copy of tnsnames.ora
    The content of tnsnames not NOT have to reflect any reality.
    I could post the content of my tnsnames.ora & it would be useless to everyone reading.

  • Sql Developer not reading right tnsnames.ora

    I have both a local 9iv2 and a 10xe (app_express) databases installed. Oracle home is set to ora92 and therefore should be reading the tnsnames.ora file in c:\oracle\ora92\network\admin. However, I recently used SQL Developer to connect to the 10xe database, and now all it reads is the tnsnames.ora file in the oraclexe\....\network\admin directory.
    Any suggestions as to how to get it to use the tnsnames.ora from the ora92 home again??
    The only solution I can think of now is to create one tnsnames.ora file with all the connections I need and copy it to each place where a tnsnames.ora file has been installed (ora92, ver 8 server, oraclexe, designer, forms/reports installs - etc.) Any other suggestions would be appreciated. I don't know why it is not reading from the specified home.
    Thanks
    Glenn

    Hi,
    This should help.
    Re: tns_admin
    -kris

  • SQLPLUS, TOAD and TNSNAMES

    I am having a look at the latest version of Toad (9.7.2.5) and have installed a virtual PC for it with a 10.2 client. I currently use version 8.0.0.47 with a 9i client and it works fine. Even though I have copied my existing SQLNET.ORA and TNSNAMES.ORA onto the virtual PC I cannot make a normal connection to the database, the new version of Toad does allow a 'Direct' as opposed to a TNS connection and if I put in the either the IP or the HOST (from TNSNAMES) along with port 1521 and the SERVICE_NAME (from TNSNAMES) I get connected to the database
    Here is the entry from my TNSNAMES.ORA
    DB_NET_SERVICE_NAME=
    (DESCRIPTION=
    (ADDRESS=
    (PROTOCOL=TCP)
    (HOST=db.office.lan)
    (PORT=1521)
    (CONNECT_DATA=
    (SERVER=dedicated)
    (SERVICE_NAME=DB_SERVICE_NAME)
    Using the TNS option, I get ORA-12154: TNS:could not resolve the connect identifier specified (DB_NET_SERVICE_NAME)
    I have checked the TNSNAMES.ORA file and it all looks OK, I have used Toad to check the syntax and it is OK
    SQLNET.ORA has
    NAMES.DEFAULT_DOMAIN = office.lan
    NAMES.DIRECTORY_PATH=(TNSNAMES, EZCONNECT)
    and either
    SQLNET.AUTHENTICATION_SERVICES=(NONE)
    or
    SQLNET.AUTHENTICATION_SERVICES=(NTS)
    I have tried both.
    I am not using TNS_ADMIN and both TNSNAMES.ORA and SQLNET.ORA are in the default directory
    Any ideas as to what is wrong?
    I can't connect in SQLPLUS either, what do I need to enter in the HOST String?

    Re NAMES.DEFAULT_DOMAIN = office.lan
    When it is commented out
    tnsping DB_NET_SERVICE_NAME gets the response
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=db.office.lan) (PORT=1521)) (CONNECT_DATA= (SERVER=dedicated) (SERVICE_NAME=DB_SERVICE_NAME)))
    OK (20 msec)
    TOAD (connecting to the DB DB_NET_SERVICE_NAME) gets the response
    ORA-12154: TNS:could not resolve the correct identifier specified (DB_NET_SERVICE_NAME)
    When it is commented back in
    tnsping DB_NET_SERVICE_NAME gets the response
    Used parameter files:
    C:\oracle\product\10.2.0\client_2\network\admin\sqlnet.ora
    TNS-03505: Failed to resolve name
    TOAD (connecting to the DB DB_NET_SERVICE_NAME) gets the response
    ORA-12154: TNS:could not resolve the correct identifier specified (DB_NET_SERVICE_NAME)

  • Oracle 8i clients, inconsistent handling of tnsnames.ora (ORA-06401 gotcha)

    This is more of a bug report / oddity declaration than a real problem, though it was a pain in the butt to nail down. I post it here for the benefit of anyone else who may run into it down the road.
    Using the linux sqlplus client, I kept getting consistent failures connecting to one of a dozen db's, but tests with the (java) netasst client worked fine. After various debugging of other potential causes, it came down to strace'ing the sqlplus client, and noting that it was attempting to connect to the wrong host, despite what was specified on the command line.
    What we identified as the most probable cause:
    The routines that load and parse the tnsnames.ora file differ between the linux and java clients, with the java client being more tolerant/robust. The tnsnames.ora file I'd been supplied with had come from a fellow user's Win32 machine, and had been edited there, which probably included a couple ^M's or other non-visible characters within the file.
    The solution (at least, what I did):
    Load the tnsnames.ora file with netasst, and save it again with netasst. Netasst wrote the file in a manner that sqlplus could read accurately, and I got to go have a beer.
    - billn

    Hi Fredrik,
    You r right. But I have its entry in tnsnames.ora file. The entry looks like this -
    My_Service_Name.world =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS =
    (COMMUNITY = tcp.world)
    (PROTOCOL = TCP)
    (Server = Computer_Name_of_Server_having_Ora8i)
    (Host = IP_Add_of_Server_having_Ora8i)
    (Port = 1521)
    (Pipe = ORAPIPE)
    (CONNECT_DATA = (SID = ORCL)
    The same entry exists in the tnsnames.ora file on the local PCs (same office where the Oracle 8i Server is present) at Site 1 and these PCs connect the server without any problem.
    Thanks
    Lokesh

  • Connect to database with SQL*Plus: is TNSNAMES.ORA used?

    Hi ,
    we have a local database called DEV01 and a duplicate of this database in a datacenter. To be able to connect to both databases the TNSNAMES.ORA
    on the local database server (not the one in the datacenter) has the following entries:
    /* Entry for local database */
    DEV01_local, DEV01_local.WORLD =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = TCP)(HOST = server01)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SID= DEV01)
    /* Entry for database in datacenter */
    DEV01,DEV01.WORLD =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = TCP)(HOST = server02)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SID = DEV01)
    When I connect to the local database server I set the Oracle-environment as follows:
    export ORACLE_SID=DEV01
    export PATH=/opt/oracle/app/oracle/product/9.2.0/bin:$PATH
    export ORACLE_HOME=/opt/oracle/app/oracle/product/9.2.0
    Now I start SQL*Plus as follows:
    oracle#> sqlplus user/user
    SQL> select instance_name, host_name from v$instance;
    INSTANCE_NAME    HOST_NAME
    DEV01            server01
    Since the SID is on both databases the same (DEV01) I really do not understand how Oracle decides to which database SQL*Plus connects to.
    Is it a matter of the entries in the TNSNAMES.ORA?
    But when I start SQL*Plus as follows:
    oracle#> sqlplus user/user@DEV01_local
    SQL> select instance_name, host_name from v$instance;
    INSTANCE_NAME    HOST_NAME
    DEV01            server01
    or
    oracle#> sqlplus user/user@DEV01
    SQL> select instance_name, host_name from v$instance;
    INSTANCE_NAME    HOST_NAME
    DEV01            server02
    everything is as expected.
    Does anybody know which database gets chosen when just connect with "sqlplus user/user" (without @DEV01 or @DEV01_local)?
    Any help will be appriciated!
    Rgds
    Jan

    Both databases have the SID=DEV01.
    The ORACLE_SID is set to DEV01 - but when connecting I end up at
    oracle#> sqlplus user/user
    SQL> select instance_name, host_name from v$instance;
    INSTANCE_NAME    HOST_NAME
    DEV01            server01
    which is the database with the TNSNAMES.ORA entry "DEV01_local, DEV01_local.WORLD = ..."
    In your case the one defined by ORACLE_SID environment variable => but which from both is it?

Maybe you are looking for