Home » Developer & Programmer » Precompilers, OCI & OCCI » OCCI Connection please help (11.01.06)
OCCI Connection please help [message #392902] Thu, 19 March 2009 10:47 Go to next message
smallshot
Messages: 1
Registered: March 2009
Junior Member
Hi everyone,

I need some help with connecting to an oracle db with the instant client 11.01.06.

I can connect to the db via other tools like sqldbx or SqlTools 1.5 which are also using oci.

So now I tried it with c++ using Visual Studio 2005 SP1.

First I tried this code:

Environment* env=Environment::createEnvironment(Environment::DEFAULT);
Connection* con=NULL;
try{
	con=env->createConnection("user","pwd","//servername:ip/mydb");
}

and got following error: "the attribute OCI_ATTR_USERNAME is greater than the maximum allowable length of 255".

So I tried:
Environment* env=Environment::createEnvironment(Environment::DEFAULT);
Connection* con=NULL;
try{
	con=env->createConnection("user","pwd","tnsservice-name");
}

where tnsservice-name is the name I specified in the tnsnams.ora, and which I used with the other tools working fine -> same error.

My username is only 4 long, so I thought it might have something to do with the string.

So I tried:
Environment* env=Environment::createEnvironment(Environment::DEFAULT);
Connection* con=NULL;
string user="user";
string passwd="pwd";
string db="tnsservice-name";

try{
	con=env->createConnection(user,passwd,db);
	AfxMessageBox("sucess");
}

now it returned the error "TNS:connect descriptor too long". Can't have anything to do with the .ora file, since it worked fine for the other tools. Plus it didn't matter if I renamed the .ora file or removed it from the TNS_ADMIN directory...

So I searched a little more for a solution and so an example, where the the last argument is missing. So I tried
string user="user";
string pwd="pwd";
Environment* env=Environment::createEnvironment(Environment::DEFAULT);
Connection* con=NULL;
try{
	con=env->createConnection(user,pwd);
}

It returns: "TNS: protocol Adapter error" which I somehow can understand, since the adapter doesn't know to wich db to connect.

I also tried to use some frameworks like soci or otl but was never able to compile them... (link errors, unknown data types etc...).

I am really running out of ideas here... Has anyone a solution and can help me please????

Thanks for any suggestions.

Re: OCCI Connection please help [message #422187 is a reply to message #392902] Tue, 15 September 2009 00:36 Go to previous message
jonowierenga
Messages: 1
Registered: September 2009
Junior Member
I have a similar problem, but with OCCI in a 10.2.0.1 client. How did you end up resolving this?

Thanks,
Jono
Previous Topic: Libgen Library not found
Next Topic: libocci.so.10.1 is empty
Goto Forum:
  


Current Time: Thu Mar 28 20:18:19 CDT 2024