最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

visual c++ - OCCI Connection Fails with ORA-01017: Invalid UsernamePassword; Logon Denied - Stack Overflow

programmeradmin1浏览0评论

I’m encountering a persistent issue with the Oracle C++ Call Interface (OCCI) when attempting to connect to an Oracle database. Despite successfully connecting to the database using SQL Plus and ODBC using C++, my OCCI code fails with the error:

ORA-01017: invalid username/password; logon denied.

Setup Details

Database Version: Oracle Database 19c (Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production) (also tested on 21c, same issue).

OCCI Version: Using the OCCI library provided with Oracle Database 19c.

Development Environment: Microsoft Visual Studio 2022 (MSVC) on Windows 11, configured with the necessary include and library paths for OCCI in Linker Input.

Environment Variables Set: ORACLE_HOME points to the Oracle database installation directory. TNS_ADMIN points to the directory containing tnsnames.ora.

OCI_LIB_DIR and OCI_INC_DIR are set to the appropriate directories as recommended.

Connection Information:

The tnsnames.ora file contains the following entry:

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

The database is open and accessible via SQL*Plus using the following command:

sqlplus TESTING/TESTING@//localhost:1521/ORCL

This successfully connects without issue.

OCCI Code

Here’s the code I’m using to connect via OCCI:

#include <occi.h>
#include <iostream>

using namespace oracle::occi;

int main() {
    string user = "TESTING";
    string pass = "TESTING";
    string connStr = "//localhost:1521/ORCL";

    try {
        Environment* env = Environment::createEnvironment(Environment::DEFAULT);
        Connection* conn = env->createConnection(user, pass, connStr);
        std::cout << "Connected to Oracle Database!" << std::endl;
        env->terminateConnection(conn);
        Environment::terminateEnvironment(env);
    } catch (SQLException& e) {
        std::cerr << "Error connecting to Oracle Database: " << e.what() << std::endl;
    }

    return 0;
}

The program compiles successfully but fails at runtime with the ORA-01017 error.

Debugging Steps Taken

Here’s what I’ve tried so far:

Connection Credentials: Verified that the username and password are correct and work in SQL*Plus. Tried different variations of the connection string (localhost:1521/ORCL, //localhost:1521/ORCL, using TNS alias and also a connect Descriptor).

Credentials: Tried renaming the password with caps and adding special characters and alphanumeric passwords and creating new users with other passwords as suggested in similar questions.

Environment Configuration: Confirmed ORACLE_HOME, TNS_ADMIN, and library paths are correctly set. Verified tnsnames.ora and ensured the service name matches the database.

SSL and Security Settings: Checked if the FIPS Algorithm Policy variable enabled in Windows is set to 0. But the issue still persists.

Database Version: Tried with Oracle 21c earlier than deinstalled and tried with 19c.

Diagnostics: Enabled OCCI tracing and reviewed logs. The logs indicate that the connection attempt reaches the database but fails at the authentication step.

SQL*Plus and ODBC: Successfully connected to the database using SQL*Plus and an ODBC instead of OCCI with ODBC data source added. But trying the OCCI code again resulted in the same error. This suggests the issue is specific to OCCI.

Other Observations: The database and client are using AL32UTF8 character set. I ensured that the credentials are passed as UTF-8 encoded strings. Connection pooling and async mode attributes were disabled for simplicity in testing.

Questions

  • What could cause OCCI to fail authentication with ORA-01017 when other tools connect successfully?
  • Is there an equivalent to SQLDriverConnect in OCCI that can be used to troubleshoot the connection process?
  • Are there specific settings or flags required for UTF-8 or Oracle wallets when using OCCI?

Any help or guidance would be greatly appreciated. I've been stuck on this for weeks and am unsure what to try next!

发布评论

评论列表(0)

  1. 暂无评论