Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can I do this using one OCIEnv handle in multi-threaded application?

569143Sep 19 2007 — edited Sep 20 2007
I create OCIEnv whit threaded parameter, then:
1. startup two threads in Windows XP, each one make a connection to same database using same OCIEnv, so I have two connection now. Then each thread query database to fetch very large recordsets, just like this:
OCIStmtPrepare2(...);
OCIStmtExecute(...);
while(...)
{
OCIStmtFetch2(...);
}
Two threads take much time to do this loop, they use different connection and different OCIStmt. I know OCIEnv has mutex for thread-safety, but when two threads run this loop at the same time, is it still safe?
2. If i use only one connection for two threads, do same opetion as above, is it still safe?

I think in any OCIXXXXX() function, OCI library can use mutex to make thread-safety, but I am not sure if consistency should be maintained in a series of OCI calls.

by the way, if I create one OCIEnv for one thread, I could create it without OCI_THREADED parameter? Is this would cause low performance?

Thanks very much!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 18 2007
Added on Sep 19 2007
3 comments
1,531 views