Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: OCI concurrent access example
"Markus M. Mueller" wrote:
> Have you tried, to give each thread a dedicated connection?
> In my application each thread has even it's own OCIEnv pointer.
>
> give it a try.
No Luck, I simplified it to just connecting an disconnecting in a loop and it
still hangs
This is simple stuff.
It is almost exactly oracle example code!
OCIInitialize((ub4) OCI_THREADED, NULL, NULL, NULL, NULL); while (1) {
OCIEnvInit(&envhp, OCI_DEFAULT, 0, (dvoid **)0);
status = OCIHandleAlloc((dvoid *)envhp, (dvoid **)&errhp, OCI_HTYPE_ERROR, 0, (dvoid **) 0);
if (status != OCI_SUCCESS)
cerr << "Alloc Error Hndl failed" << endl;
status = OCIHandleAlloc((dvoid *) envhp, (dvoid **) &srvhp, OCI_HTYPE_SERVER, (size_t) 0, (dvoid **) 0);
check_status(status);
status = OCIHandleAlloc((dvoid *) envhp, (dvoid **) &svchp, OCI_HTYPE_SVCCTX, (size_t) 0, (dvoid **) 0);
check_status(status);
// This is the call that hangs!! periodically
status = OCIServerAttach(srvhp, errhp, (text *)0, 0, OCI_DEFAULT); check_status(status);
status = OCIAttrSet((dvoid *) svchp, OCI_HTYPE_SVCCTX, (dvoid *)srvhp, (ub4) 0, OCI_ATTR_SERVER, (OCIError *) errhp);
check_status(status);
status = OCIHandleAlloc((dvoid *) envhp, (dvoid **)&authp, (ub4) OCI_HTYPE_SESSION, (size_t) 0, (dvoid **) 0);
check_status(status);
status = OCIAttrSet((dvoid *) authp, (ub4) OCI_HTYPE_SESSION,
(dvoid *) "snoopdogg", (ub4) strlen((char *)"snoopdogg"), (ub4) OCI_ATTR_USERNAME, errhp);check_status(status);
status = OCIAttrSet((dvoid *) authp, (ub4) OCI_HTYPE_SESSION,
(dvoid *) "thepass", (ub4) strlen((char *)"thepass"), status = OCISessionBegin(svchp, errhp, authp, OCI_CRED_RDBMS, (ub4) OCI_DEFAULT);
status = OCIAttrSet((dvoid *) svchp, (ub4) OCI_HTYPE_SVCCTX,
(dvoid *) authp, (ub4) 0, (ub4) OCI_ATTR_SESSION, errhp);check_status(status);
/// Clean up and disconnect
status = OCISessionEnd(svchp, errhp, authp,
(ub4) OCI_DEFAULT);
check_status(status);
status = OCIServerDetach(srvhp, errhp, OCI_DEFAULT); check_status(status);
status = OCIHandleFree(authp, OCI_HTYPE_SESSION); check_status(status);
status = OCIHandleFree(srvhp, OCI_HTYPE_SERVER); check_status(status);
status = OCIHandleFree(svchp, OCI_HTYPE_SVCCTX); check_status(status);
status = OCIHandleFree(errhp, OCI_HTYPE_ERROR); check_status(status);
if (envhp) {
status = OCIHandleFree(envhp, OCI_HTYPE_ENV); if (status != OCI_SUCCESS) cerr << "Release Oracle environment handle failed";}
![]() |
![]() |