Beispiel #1
0
bool oci_create_tns_seesion_pool(const unsigned char * connect_str, const int connect_str_len,
                                 const unsigned char * user_name, const int user_name_len,
                                 const unsigned char * password, const int password_len,
                                 const unsigned char * options, const int options_len)
{
    function_success = SUCCESS;
    poolName = NULL;
    poolNameLen = 0;

    oci_free_session_pool();

    /* allocate session pool handle
     * note: for OCIHandleAlloc() we check error on environment handle
     */
    checkenv(envhp, OCIHandleAlloc(envhp, (void **)&spoolhp,
                                   OCI_HTYPE_SPOOL, (size_t) 0, (void **) NULL));

    /* set the statement cache size for all sessions in the pool
     * note: this can also be set per session after obtaining the session from the pool
     */
    checkerr(errhp, OCIAttrSet(spoolhp, OCI_HTYPE_SPOOL,
                               &stmt_cachesize, 0, OCI_ATTR_SPOOL_STMTCACHESIZE, errhp));

    checkerr(errhp, OCISessionPoolCreate(envhp, errhp,
                                         spoolhp,
                                         (OraText **) &poolName, &poolNameLen,
                                         (OraText *) connect_str, connect_str_len,
                                         POOL_MIN, POOL_MAX, POOL_INCR,
                                         (OraText*)user_name, user_name_len,			/* h**o pool user specified */
                                         (OraText*)password, password_len,			/* h**o pool password specified */
                                         OCI_SPC_STMTCACHE));	/* modes */
    if(function_success != SUCCESS)return false;

    sprintf_s(session_pool_name, sizeof(session_pool_name), "%.*s", poolNameLen, (char *)poolName);

    ub1 spoolMode = OCI_SPOOL_ATTRVAL_NOWAIT;
    checkerr(errhp, OCIAttrSet(spoolhp, OCI_HTYPE_SPOOL,
                               (void*)&spoolMode, sizeof(ub1),
                               OCI_ATTR_SPOOL_GETMODE, errhp));
    if(function_success != SUCCESS)return false;

    return true;
}
Beispiel #2
0
static void create_session_pool(OCIEnv *envhp, OCIError * errhp,
                         char **poolName, ub4 *poolNameLenp)
{
  ub4       stmt_cachesize = 20;
  ub4  min;                            /* minimum number of sessions in pool */
  ub4  max;                            /* maximum number of sessions in pool */
  ub4  increment;                     /* the number to increment the pool by */

  /* allocate session pool handle
   * note: for OCIHandleAlloc(), we check error on environment handle
   */
  checkenv(envhp, OCIHandleAlloc(envhp, (void **) &spoolhp,
           OCI_HTYPE_SPOOL, (size_t) 0, (void **) NULL));

  /* set the statement cache size for all sessions in the pool */
  checkerr(errhp, OCIAttrSet(spoolhp, OCI_HTYPE_SPOOL,
                  &stmt_cachesize, 0, OCI_ATTR_SPOOL_STMTCACHESIZE, errhp));

  min = thread_num;                    /* minimum number of sessions in pool */
  max = thread_num + 1;                /* maximum number of sessions in pool */
  increment = 1;                      /* the number to increment the pool by */

  /* create a homogeneous session pool */
  checkerr(errhp,
           OCISessionPoolCreate(envhp, errhp,
                                spoolhp,              /* session pool handle */
                                                /* returned poolname, length */
                                (OraText **) poolName, poolNameLenp,
                                                           /* connect string */
                                (const OraText *) connstr, strlen(connstr),
                                min, max, increment,/* pool size constraints */
                                                                 /* username */
                                (OraText *) username,strlen((char *) username),
                                                                 /* password */
                                (OraText *) apppassword,
                                strlen((char *) apppassword),
                                                                    /* modes */
                                OCI_SPC_HOMOGENEOUS|OCI_SPC_STMTCACHE));
}