I am trying to port an application from Solaris to Linux.
On Solaris, I used the Sun Studio C++ compiler, and on Linux, I used the Intel C++ compiler.
Now, I am facing the following problem while connecting to oracle database:
OCIDBConnection::OCIDBConnection(
Environment& _env, const STRING& dbName, const STRING& user, const STRING& password)
: env(_env)
{
COUT<<"username "<<user<<ENDL;
COUT<<"password "<<password<<ENDL;
COUT<<"dbname "<<dbName<<ENDL;
conn = env.createConnection(user, password, dbName);
}
The output comes out like :
username roymustang9
password roymustang9
dbname roydb
[2013-11-12 15:39:23]>>FATAL<<: Login failed.
And on printing the SQLException, I find:
ORA-12154: TNS:could not resolve the connect identifier specified
which is ridiculous, because the name exists in the tnanames.ora, and the connection details are right. Infact, when I hardcode the values, it goes through fine:
OCIDBConnection::OCIDBConnection(
Environment& _env, const STRING& dbName, const STRING& user, const STRING& password)
: env(_env)
{
COUT<<"username "<<user<<ENDL;
COUT<<"password "<<password<<ENDL;
COUT<<"dbname "<<dbName<<ENDL;
conn = env.createConnection("roymustang9", "roymustang9", "roydb");
}
STRING is a typedef defined as std::string. COUT and ENDL are typedefs of std::cout and std::endl as well.
What am I missing here? http://docs.oracle.com/cd/B28359_01/appdev.111/b28390/reference014.htm#CHEEGFAI