This discussion is archived
1 Reply Latest reply: Apr 3, 2012 3:18 AM by 423410 RSS

C++ OCI LOGON problem for Unicode Characterset

926903 Newbie
Currently Being Moderated
I am trying to connect to Oracle 10g through C++ Code using OCI API on window.The database is multilingual currently I am having Hebrew.I can easily connect and can do any processing when database is not in Unicode.But i am getting logon problem in unicode database.

steps which i am following

const wchar_t username[] = L"usr"; const wchar_t password[] = L"pwd";

const wchar_t connstring[] = L"(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ServerIP)(PORT=1521))(CONNECT_DATA=(SID=orcl)))";

const wchar_t query[] = L"select TO_CHAR('הקוד'),TO_CHAR('COL_1') FROM TMA.הקודש";

I am creating Environment through this function

rc = OCIEnvNlsCreate((OCIEnv **)&env, (ub4)0, (dvoid *)0, (dvoid () (dvoid *, size_t)) 0, (dvoid () (dvoid *, dvoid *, size_t)) 0, (dvoid(*) (dvoid , dvoid )) 0, (size_t) 0, (dvoid **)0, (ub2)OCI_UTF16ID, /* Metadata and SQL CHAR character set */ (ub2)OCI_UTF16ID /* SQL NCHAR character set */); the return code for this step is success full.

Server Attach

rc = OCIServerAttach(srv, err, (const text*)connstring, (sb4) sizeof(connstring), (ub4) OCI_DEFAULT); the return code for this step is also success full.

Username attribute setting rc = OCIAttrSet((dvoid *) ses, (ub4) OCI_HTYPE_SESSION, (dvoid ) ((text*)username), (ub4) wcslen(username), OCI_ATTR_USERNAME, err);

password attribute setting rc = OCIAttrSet((dvoid *) ses, (ub4) OCI_HTYPE_SESSION, (dvoid ) ((text*)password), (ub4) wcslen(password), OCI_ATTR_PASSWORD, err);

Beginning Session rc = OCISessionBegin(svc, err, ses, (ub4) OCI_CRED_RDBMS, (ub4) OCI_DEFAULT);

After this step I am getting this error

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

I am setting all necessary handles and attributes which is required.

Any solution??

Edited by: 923900 on Mar 28, 2012 12:48 AM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points