Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> OCI with a Multithreading App
Hi - I am trying to figure out how to initialize OCI so that threads in a multithreaded app do not block each other.
The app creates threads T1, T2 both of which connect to the Oracle
database to perform SQL.
T1 connects and starts processing SQL insert and selects. T2 starts and
connects OK - however at this
point T2 tries to process its SQL statements but ends up blocked,
waiting for T1. When T1 finsishes T2 starts it
processsing.
So the question is how to allow T1 and T2 to operate without blocking.
Both T1 and T2 have created their own
OCI Environment handle and login under that handle. The handle is
created with OCIEnvCreate with OCI_DEFAULT
as the mode. They also have their own error and service context handles.
When I tried OCI_THREADED as the mode for the OCIEnvCreate I get a
access violation when disconnecting T1.
Its not clear from the OCI doc whether I need to specify OCI_THREADED
as the mode
in OCIEnvCreated - anyone know about this?
I also tried to have T1 and T2 share the same OCI Environment handle.
With OCI_DEFAULT T1 blocked T2.
With OCI_THREADED I get the same access violation.
The Ora doc is on this is confusing to say the least.. Any help much appreciated.
Regards
David Murphy
NetDirect_at_compuserve.com
The sequence of calls for each thread is ..
OCIEnvCreate(&OCIEnvHandle, OCI_DEFAULT /*OCI_THREADED*/ ,
NULL, NULL, NULL, NULL, 0, NULL); OCIHandleAlloc((dvoid *) OCIEnvHandle, (dvoid **) &OCIErrorHandle, (ub4) OCI_HTYPE_ERROR, (size_t) 0, (dvoid **) 0);
OCILogon((OCIEnv *) OCIEnvHandle, OCIErrorHandle, &OCISvcHandle, ..)
OCIHandleAlloc((dvoid *)pConnection->OCIEnvHandle, (dvoid **) &OCIStatementHandle,
(ub4)OCI_HTYPE_STMT, (CONST size_t) 0,(dvoid **) 0);
OCIStmtExecute(pConnection->OCISvcHandle,
OCIStatementHandle, pConnection->OCIErrorHandle,
(ub4) nIterations,
(ub4) 0,
(OCISnapshot *) NULL,
(OCISnapshot *) NULL,
(ub4) OCI_DEFAULT);
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Sun Jun 18 2000 - 00:00:00 CDT