Error "ORA-01017: invalid username/password; logon denied" when trying to connect to Oracle Database using OCCI and GCC

huangapple go评论62阅读模式
英文:

Error "ORA-01017: invalid username/password; logon denied" when trying to connect to Oracle Database using OCCI and GCC

问题

这是我们在使用GCC连接Oracle数据库时遇到的问题。目前,客户端和服务器都在相同的环境下运行,该环境运行着RHEL 8。我们正在将操作系统从CentOS 7迁移到RHEL 8的过程中,当在CentOS 7下运行相同的应用程序代码时,它可以成功连接并查询数据库。

以下是应用程序代码:

#include <occi.h>

if (!oracleEnvironment) oracleEnvironment = oracle::occi::Environment::createEnvironment();
oracle::occi::Connection *databaseConnection = oracleEnvironment-createConnection("our_username", "our_password");

我们知道我们正在使用的用户名和密码是正确的(尽管它们在我发布的代码示例中已被更改),因为我们通过在同一台机器上运行sqlplus并使用该用户名和密码进行连接来验证了这一点。

因此,当我们在CentOS 7和gcc 10.2.1下运行时,它可以正常工作。但是在RHEL 8和gcc 10.3.1下运行相同的代码时,它就不行了,并且我们得到了Oracle的错误。有时候,我们还会遇到错误“ORA-24960:属性OCI_ATTR_USERNAME大于最大允许的长度255”,而不是无效的用户名/密码错误。但同样,在CentOS 7下可以正常工作,但在RHEL 8下不行。

我怀疑ORA-01017错误和ORA-24960错误是相关的,或者可能有相同的根本原因,因为我找到了以下问题,所有这些问题的答案都建议相同的解决方法,即更改GCC标志_GLIBCXX_USE_CXX11_ABI

然而,我尝试更改该标志并重新构建我的应用程序,但仍然遇到了相同的问题。

这些问题中的前两个答案似乎暗示,当前版本的GCC(可能自GCC 7以来)与当前版本的Oracle OCCI 不兼容。但GCC 7已经可用超过6年了。那么这是否真的是情况?

英文:

This is an issue we have connecting to Oracle Database using GCC. Currently both the client and the server are running under the same environment, which is running RHEL 8. We are in the process of migrating the OS from CentOS 7 to RHEL 8, and the identical application code successfully connects to and queries the database when run under CentOS 7.

Here is the application code:

#include &lt;occi.h&gt;

if (!oracleEnvironment) oracleEnvironment = oracle::occi::Environment::createEnvironment();
oracle::occi::Connection *databaseConnection = oracleEnvironment-createConnection(&quot;our_username&quot;, &quot;our_password&quot;);

We know that the username and password we are using are correct (though they've been altered in the code sample I posted here), since we have validated this by running sqlplus on the same machine and connecting with that username and password.

So when we run this under CentOS 7 and gcc 10.2.1, it works fine. But the same thing under RHEL 8 and gcc 10.3.1, it does not, and we get that Oracle error. Sometimes we've also gotten the error "ORA-24960: the attribute OCI_ATTR_USERNAME is greater than the maximum allowable length of 255" instead of the invalid username/password error. But again, this works fine under CentOS 7 but not RHEL 8.

I suspect that the ORA-01017 error and the ORA-24960 error are related or maybe have the same underlying cause, since I found the following questions which all have answers suggesting the same solution, which is to change the value of the GCC flag _GLIBCXX_USE_CXX11_ABI:

However, I tried changing that flag and rebuilding my application and I still encountered the same problem.

The answers in the first two of these questions seem to suggest that the current versions of GCC (possibly since GCC 7) are not compatible with current version's of Oracle's OCCI. But GCC 7 has already been available for more than 6 years. So is this really the case?

答案1

得分: 0

@ChristopherJones在评论中建议我查看Oracle的文档,以确定Oracle表示与我的Oracle软件版本兼容的GCC版本。我最终在Oracle的这个链接中找到了以下信息:

> 注意:对于在Linux-x86-64上使用g++5.3、g++6.3、g++7.3和g++8的OCCI应用程序,不要链接到libocci.so.21.1库,而应链接到$ORACLE_HOME/lib/libocci_gcc53.so.21.1库。

因此,链接到这个替代库似乎解决了问题。

英文:

@ChristopherJones suggested in a comment to the question, that I look at Oracle's documentation to find out what version of GCC Oracle says is compatible with my version of the Oracle software. I did eventually find this from Oracle, which states:

> Note: For OCCI applications on Linux-x86-64 using g++5.3, g++6.3, g++7.3 and g++8, instead of the libocci.so.21.1 library, link to the $ORACLE_HOME/lib/libocci_gcc53.so.21.1 library.

So, linking to this alternate library seems to have solved it

huangapple
  • 本文由 发表于 2023年7月18日 01:50:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76706970.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定