我正在尝试在 Ubuntu 上运行以下测试程序以使用即时客户端 OCCI 库连接到 oracle 数据库。
#include <iostream>
#include <occi.h>
using namespace oracle::occi;
int main() {
Environment *env = Environment::createEnvironment(Environment::DEFAULT);
Connection *conn = env->createConnection( "user", "1234" );
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
}
编译时没有错误
g++ main.cpp -L ~/instantclient_12_2 -locci -lclntsh -I ~/instantclient_12_2/sdk/include
但是在运行的时候我得到
terminate called after throwing an instance of 'oracle::occi::SQLException'
what(): ORA-24960: the attribute OCI_ATTR_USERNAME is greater than the maximum allowable length of 255
Aborted
我正在运行 Ubuntu 16.04、gcc 5.4.0,我在即时客户端 11.2 和 12.2 上得到了相同的结果。
之前有人问过:https://stackoverflow.com/questions/40022118/ora-24960-the-attribute-oci-attr-username-is-greater-than-the-maximum但答案不适用于 linux(或者我忽略了这一点)。
如有任何帮助,我们将不胜感激。
最佳答案
通过恢复到较旧的编译器解决了问题。
$ sudo apt-get install g++-4.8
$ g++-4.8 main.cpp -L ~/instantclient_12_2 -locci -lclntsh -I ~/instantclient_12_2/sdk/include
可能最新的编译器和库与用于构建 OCCI 库的编译器和库不兼容。
关于oracle - Ubuntu ORA-24960 : the attribute OCI_ATTR_USERNAME is greater than the maximum allowable length of 255,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42890553/