Home » RDBMS Server » Networking and Gateways » C++ and error ORA-12154 (Oracle Express and Visual Studio 2010)
C++ and error ORA-12154 [message #516774] Wed, 20 July 2011 14:50 Go to next message
rassul
Messages: 3
Registered: November 2003
Junior Member
The following program compiles but gets the runtime error:
ORA-12154: TNS:could not resolve the connect identifier specified

I am using Windows 7 and Microsoft compiler cl.exe of Visutal Studio 2010.

Please help. 

// Program name: p1.cpp
#include <iostream>
#include <occi.h>
using namespace std;
using namespace oracle::occi;
int main()
{
    const string user = "HR"; 
    const string pass = "HR"; 
    const string osid = "XE";

    Environment* const env = 
        Environment::createEnvironment(Environment::DEFAULT);
    int ret = 0;
    try
    {
        Connection* const con = 
            env->createConnection(user, pass, osid);
        cout << "Connected!" << endl;
        env->terminateConnection(con);
    }
    catch(SQLException &e)
    {
        cout<<e.what();
    }
    return ret;
}

-----------------------------------------------------------------------
Microsoft compiler command line:
cl.exe /EHsc p1.cpp oraocci10.lib

-----------------------------------------------------------------------
C:\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN\tnsnames.ora
XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = VOSTRO-1510)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XE)
    )
  )

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

ORACLR_CONNECTION_DATA = 
  (DESCRIPTION = 
    (ADDRESS_LIST = 
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE)) 
    ) 
    (CONNECT_DATA = 
      (SID = CLRExtProc) 
      (PRESENTATION = RO) 
    ) 
  ) 
-----------------------------------------------------------------------
C:\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN\listener.ora
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\10.2.0\server)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\10.2.0\server)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
      (ADDRESS = (PROTOCOL = TCP)(HOST = VOSTRO-1510)(PORT = 1521))
    )
  )

DEFAULT_SERVICE_LISTENER = (XE)
--------------------------------------------------------------------------
Environment variables:
ORACLE_HOME=ORACLE_HOME=C:/oraclexe/app/oracle/product/10.2.0/server
Re: C++ and error ORA-12154 [message #516784 is a reply to message #516774] Wed, 20 July 2011 18:14 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
When was last time this client successfully connected to DB?
What changed since then?

>ORA-12154: TNS:could not resolve the connect identifier specified
I understand what you posted, but my reality is to believe Oracle error message tell the truth.

ORA-12154 ALWAYS only occurs on SQL Client & no SQL*Net packets ever leave client system
ORA-12154 occurs when client requests a connection to some DB server system using some connection string.
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.

Does any other software exist on remote client that could be used to independently test SQL*Net connection to DB Server?

[Updated on: Wed, 20 July 2011 18:15]

Report message to a moderator

Re: C++ and error ORA-12154 [message #516799 is a reply to message #516774] Wed, 20 July 2011 23:29 Go to previous message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
ORACLE_HOME=ORACLE_HOME=C:/oraclexe/app/oracle/product/10.2.0/server

So ORACLE_HOME is not correct as it contains "ORACLE_HOME=".

Regards
Michel
Previous Topic: ORA-12170: TNS:Connect timeout occurred
Next Topic: Objects refering to db links
Goto Forum:
  


Current Time: Thu Mar 28 12:47:08 CDT 2024