I'm getting the following exception "ORA-24960: the attribute OCI_ATTR_USERNAME is greater than the maximum allowable length of 255" when using Environment:createConnection.
I'm using VisualC++ 8.0 and Oracle 10g R 10.2.0.


Below is the snippet of code that creates the problem:

#include <iostream>
#include<occi.h>
using namespace oracle:cci;
using namespace std;

try{

Environment *env = Environment::createEnvironment(Environment:EFAULT);
Connection *conn = env->createConnection ("scott","tiger");

}
catch(SQLException ex)
{
cout << ex.getMessage(); //throws 24960 error 
}
K._106 commented: Using the debug library (oraocci11d.lib, vc9) in debug mode did the trick for me (VS2008, v90). +0

Dani AI

Generated

Good catch by on the typo, but ORA-24960 in this tiny example almost never means your username is too long. It is a classic symptom of an ABI/library mismatch: the OCCI DLL your app loads was built with a different C++ runtime than your compiler, so OCCI misreads the username buffer length and throws 24960. With VS2005 (VC8), this typically happens if you link to Oracle 10gR2 client libraries that were produced for VC7.0/VC7.1. Oracle’s 10.2 docs list only VC7.x OCCI libraries; VC8 builds arrived with later clients. (docs.oracle.com)

What to do on Windows with VC8:

  • Use an Oracle client that ships VC8 OCCI libraries (for example, 11gR1+). You should see vc8-specific libs under ORACLE_HOME\oci\lib\msvc\vc8, and link/run against those. (docs.oracle.com)
  • If you must stay on 10.2, build the app with VC7.1 (VS2003) to match the 10.2 OCCI binaries, or move to an 11g Instant Client on the dev box while continuing to connect to your 10g database. The 10.2 docs explicitly call out only vc7/vc71 locations for oraocci10.*. (docs.oracle.com)
  • Make sure PATH points first to the intended ORACLE_HOME\bin so you do not accidentally load an older oraocci*.dll at runtime; also match debug vs release (oraocci10d/11d for /MDd). (docs.oracle.com)

If you want extra confirmation that this is an ABI issue, note that others hit the identical ORA-24960 when compiling OCCI with a newer toolchain on Linux; reverting to a toolset that matches Oracle’s build (or using the older C++ ABI) resolves it. Different platform, same root cause. ()

Once your OCCI DLLs match your compiler runtime, your original createConnection("scott","tiger") call should work as-is.

Recommended Answers

All 4 Replies

There's a typo in your code. I think you mean Environment::DEFAULT instead of Environment:EFAULT . I never heard of the second anyway ;)

Environment *env = Environment::createEnvironment(Environment:: DEFAULT ); i type but same problem

Here's a related thread, maybe it can help you

and this will help everyone a LOT !!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.