hey,
I am trying to do this, using oci connect to a database in THREADED mode and after processing some selects and updates, close the connection. The application then sleeps for a few and connects again to the database.
The issue is the app runs fine for few hours but then crashes without any error from ORACLE. The crash happens when the app tries to connect to Oracle to run a select.
i have wrapped oci calls and use them as shared libs.
* connect module - this is how i create the env and connect to db
if (!oci_env_created) {
r=OCIEnvCreate( &conn->env,
OCI_DEFAULT |
OCI_THREADED
, 0, 0, 0, 0, 0, 0);
if (r != OCI_SUCCESS) {
strcpy(errmsg,"Could not create environment (OCIEnvCreate)";
goto clean_up;
}
oci_env_created = 1;
}
OCIHandleAlloc(conn->env, (dvoid**)&conn->err, OCI_HTYPE_ERROR, 0, 0);
OCIHandleAlloc(conn->env, (dvoid**)&conn->srv, OCI_HTYPE_SERVER, 0, 0);
OCIHandleAlloc(conn->env, (dvoid**)&conn->svc, OCI_HTYPE_SVCCTX, 0, 0);
OCIHandleAlloc(conn->env, (dvoid**)&conn->ses, OCI_HTYPE_SESSION, 0, 0);
r=OCIServerAttach(conn->srv, conn->err, dbname, strlen((const char*)dbname), (ub4) OCI_DEFAULT);
if (r != OCI_SUCCESS) {
checkerr(conn->err, r, errmsg);
goto clean_up;
}
OCIAttrSet(conn->svc, OCI_HTYPE_SVCCTX, conn->srv, 0, OCI_ATTR_SERVER, conn->err);
OCIAttrSet(conn->ses, OCI_HTYPE_SESSION, username, strlen((const char*)username), OCI_ATTR_USERNAME, conn->err);
OCIAttrSet(conn->ses, OCI_HTYPE_SESSION, password, strlen((const char*)password), OCI_ATTR_PASSWORD, conn->err);
if ( (r=OCIAttrSet((dvoid *) conn->svc, (ub4) OCI_HTYPE_SVCCTX, (dvoid *) conn->ses, (ub4) 0, (ub4) OCI_ATTR_SESSION, conn->err)) ) {
checkerr(conn->err, r,errmsg);
goto clean_up;
}
r=OCISessionBegin (conn->svc, conn->err, conn->ses, OCI_CRED_RDBMS, OCI_DEFAULT);
if (r != OCI_SUCCESS) {
checkerr(conn->err, r,errmsg);
goto clean_up;
}
* following is the code for terminating the connection
if ((r = OCIHandleFree((dvoid*) sh, (ub4) OCI_HTYPE_STMT))) {
checkerr(conn->err, r, (text*)errmsg);
return 0;
}
if ((r = OCISessionEnd(conn->svc, conn->err, conn->ses, OCI_DEFAULT))) {
checkerr(conn->err, r, (text*)errmsg);
return 0;
}
if ((r = OCIServerDetach(conn->srv, conn->err, OCI_DEFAULT))) {
checkerr(conn->err, r, (text*)errmsg);
return 0;
}
if ((r = OCIHandleFree((dvoid*) conn->svc, (ub4) OCI_HTYPE_SVCCTX))) {
checkerr(conn->err, r, (text*)errmsg);
return 0;
}
if ((r = OCIHandleFree((dvoid*) conn->srv, (ub4) OCI_HTYPE_SERVER))) {
checkerr(conn->err, r, (text*)errmsg);
return 0;
}
if ((r = OCIHandleFree((dvoid*) conn->err, (ub4) OCI_HTYPE_ERROR))) {
return 0;
}
return 1;
any insight is appreciated
thanks