Hi,
I trying to write some small application on a 32bit Centos machine, with g++ and OCCI, I have correctly setup the library linking and have some sample code running alright, however I don't seem to be able to get a correct connection string to connect to a remote 11g database (11.0.2.3).
below are codes that I have tried.
[code]
#include <occi.h>
#include <iostream>
using namespace std;
using namespace oracle::occi;
int main(){
string userName = "user";
string password = "STRONGPW";
string connectString = "";
try{
Environment *env = Environment::createEnvironment();
{
cout << "before create connection\n";
Connection *conn = env->createConnection(userName, password, connectString);
}
Environment::terminateEnvironment(env);
}catch(exception& e){
cout << e.what();
}
}
[/code]
I have double confirmed the username and password, and whenever it goes the createConnection method, it will throw exception error,
I am compiling and running as root, I have tried all sort of connection strings
connectionString = "";
ORA-12546: TNS:permission denied
connectString = "TCP://192.168.1.2:1522"; // I did also try "tcp://192.168.1.2:1522"
ORA-12154: TNS:could not resolve the connect identifier specified (192.168.1.2 being host machine, 1522 being listening port)
connectString = "User Id=user;Password=STRONGPW;Data Source=ORCL222";
ORA-12154: TNS:could not resolve the connect identifier specified (ORCL222 being name specified in $ORACLE_HOME/network/admin/tnsnames.ora)
connectString = "DataSource=" // I did try "ORCL222="
" (DESCRIPTION ="
" (ADDRESS=(PROTOCOL = TCP)(HOST = 192.168.1.2)(PORT = 1522))"
" (CONNECT_DATA="
" (SERVICE_NAME = ORCL2)"
" (SERVER = DEDICATED)"
" )"
" )"
ORA-12154: TNS:could not resolve the connect identifier specified (ORCL2 being ORACLE service name)
did I miss anything? or is there any spacing in the connection string that I might have did wrongly?