Home » SQL & PL/SQL » SQL & PL/SQL » Issue in Database Link (Oracle Database 11g Enterprise Edition 11.2.0.1.0 - 64bit)
Issue in Database Link [message #606183] Mon, 20 January 2014 23:55 Go to next message
Manoj.Gupta.91
Messages: 239
Registered: March 2008
Location: Delhi
Senior Member
Hi All,

I'm facing an issue while using a DB Link.

I've two oracle databases. DB1 and DB2. I'm following the same procedure to create database link on DB1 for DB2 and on DB2 for DB1. One of them is working perfectly fine by another one is not.

--On DB1
CREATE DATABASE LINK DBLNK_DB2
CONNECT TO myuser
IDENTIFIED BY myuser
USING  '10.10.1.250:1521/DB2' ;  

SELECT * FROM myuser.mytable@DBLNK_DB2 ;

--above query is giving below error.

ORA-12154: TNS:could not resolve the connect identifier specified
12154. 00000 -  "TNS:could not resolve the connect identifier specified"
*Cause:    A connection to a database or other service was requested using
           a connect identifier, and the connect identifier specified could not
           be resolved into a connect descriptor using one of the naming methods
           configured. For example, if the type of connect identifier used was a
           net service name then the net service name could not be found in a
           naming method repository, or the repository could not be
           located or reached.
*Action:   
           - If you are using local naming (TNSNAMES.ORA file):
           - Make sure that "TNSNAMES" is listed as one of the values of the
           NAMES.DIRECTORY_PATH parameter in the Oracle Net profile
           (SQLNET.ORA)
           - Verify that a TNSNAMES.ORA file exists and is in the proper
           directory and is accessible.
           - Check that the net service name used as the connect identifier
           exists in the TNSNAMES.ORA file.
           - Make sure there are no syntax errors anywhere in the TNSNAMES.ORA
           file.  Look for unmatched parentheses or stray characters. Errors
           in a TNSNAMES.ORA file may make it unusable.
           - If you are using directory naming:
           - Verify that "LDAP" is listed as one of the values of the
           NAMES.DIRETORY_PATH parameter in the Oracle Net profile
           (SQLNET.ORA).
           - Verify that the LDAP directory server is up and that it is
           accessible.
           - Verify that the net service name or database name used as the
           connect identifier is configured in the directory.
           - Verify that the default context being used is correct by
           specifying a fully qualified net service name or a full LDAP DN
           as the connect identifier
           - If you are using easy connect naming:
           - Verify that "EZCONNECT" is listed as one of the values of the
           NAMES.DIRETORY_PATH parameter in the Oracle Net profile
           (SQLNET.ORA).
           - Make sure the host, port and service name specified
           are correct.
           - Try enclosing the connect identifier in quote marks.
Error at Line: 13 Column: 33


If I follow the same procedure on DB2 to create DB link for DB1 it's working perfectly fine.

Please help me to resolve this issue.


Thanks & Regards
Manoj
Re: Issue in Database Link [message #606184 is a reply to message #606183] Mon, 20 January 2014 23:57 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member

ORA-12154 ALWAYS only occurs on SQL Client & no SQL*Net packets ever leave client system
ORA-12154 NEVER involves the listener, the database itself or anything on the DB Server.
ORA-12154 occurs when client requests a connection to some DB server system using some connection string.
TNS-03505 is thrown by tnsping & is same error as ORA-12154 thrown by sqlplus or others.
The lookup operation fails because the name provided can NOT be resolved to any remote DB.
The analogous operation would be when you wanted to call somebody, but could not find their name in any phonebook.
The most frequent cause for the ORA-12154 error is when the connection alias can not be found in tnsnames.ora.
The lookup operation of the alias can be impacted by the contents of the sqlnet.ora file; specifically DOMAIN entry.
TROUBLESHOOTING GUIDE: ORA-12154 & TNS-12154 TNS:could not resolve service name [ID 114085.1]
http://edstevensdba.wordpress.com/2011/02/26/ora-12154tns-03505/
Re: Issue in Database Link [message #606186 is a reply to message #606184] Tue, 21 January 2014 00:20 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

In addition, it is the SERVER tnsnames.ora you have to check.

Re: Issue in Database Link [message #606189 is a reply to message #606186] Tue, 21 January 2014 00:45 Go to previous messageGo to next message
Manoj.Gupta.91
Messages: 239
Registered: March 2008
Location: Delhi
Senior Member
Hi All,

Thanks for your help and support.

It worked when I did these steps.

--TNS entry on DB1.
DB2 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.1.250)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = DB2)
    )
  )

--DB Link on DB1.

CREATE DATABASE LINK DBLNK_DB2
CONNECT TO myuser
IDENTIFIED BY myuser
USING  'DB2' ;  



When I tried to create db link as below. There was still an issue.
CREATE DATABASE LINK DBLNK_DB2
CONNECT TO myuser
IDENTIFIED BY myuser
USING  '10.10.1.250:1521/DB2' ; 


I want to know what is the difference in creating DB link using these two approaches?
Why first approach worked but second approach still throws an error?

Please help me find answers to these questions coming in my mind.


Thanks & Regards
Manoj
Re: Issue in Database Link [message #606193 is a reply to message #606189] Tue, 21 January 2014 01:14 Go to previous message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
USING  '10.10.1.250:1521/DB2' ; 

should be "USING 'DB2'" or "USING 'DB2.domain_name'" if a default domain is given in sqlnet.ora.

[Updated on: Tue, 21 January 2014 01:14]

Report message to a moderator

Previous Topic: The INTO clause of a SELECT statement of PL/SQL block
Next Topic: UTL_SMTP
Goto Forum:
  


Current Time: Thu Mar 28 16:07:14 CDT 2024