1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
| #include <stdio.h>
#include <string.h>
#include <oci.h>
#include <ocidfn.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
/* Oracleユーザ情報 */
//static const char* dbname = "est";
//static const char* orauser = "USR_CRMP";
//static const char* orapasswd = "SR_CRMP";
//static const char* username = "USR_CRMP";
//static const char* passwd = "USR_CRMP";
static const char* username = "scott";
static const char* passwd = "tiger";
static const char* target_db = "test";
static const char* connMin = "20";
static const char* connMax = "20";
static const char* connInc = "1";
int main(int argc, char* argv[])
{
int i=0;
text errbuf[512];
ub4 buflen;
sb4 errcode;
OCIError* err = (OCIError*)malloc(sizeof(OCIError*));
//memset(err, 0, sizeof(OCIError));
static OCIEnv* envhp; /* OCI環境ハンドル */
static OCIError* errhp; /* エラーハンドル */
static OCISvcCtx** svchp; /* サービスコンテキストハンドル */
OCISPool *spoolhp; //! セッションプール・ハンドル
//printf("sizeof(wchar_t) = %i\n",sizeof(wchar_t));
//printf("sizeof(char) = %i\n",sizeof(char));
OraText *poolName = (OraText*)"orcl"; //! セッショ
sb4 poolNameLen ; //! セッションプー
int connMax = 20; //! コネクション最大数
int connMin = 20; //! コネクション最小数
int connInc = 1; //! コネクションインクリメント幅
sword status = OCI_SUCCESS;
for(i=0; i<127; i++){
/* 環境ハンドルの初期化 */
status = OCIEnvCreate(&envhp, OCI_DEFAULT, NULL, NULL, NULL,
NULL, 0, NULL);
printf("1.0 errno = %s\n", strerror(errno));
printf("status OCIEnvCreat%d\n",status);
/* エラーハンドルの割り当て */
status = OCIHandleAlloc(envhp, (dvoid**)&errhp, OCI_HTYPE_ERROR,
0, NULL);
printf("1.1 errno = %s\n", strerror(errno));
printf("status OCIHandleAlloc%d\n",status);
status = OCIHandleAlloc(envhp, (dvoid **)&spoolhp,
OCI_HTYPE_SPOOL, (size_t) 0, (dvoid **)
0);
printf("1.2 errno = %s\n", strerror(errno));
printf("status OCIHandleAlloc%d\n",status);
// セッションプール生成
status = OCISessionPoolCreate((OCIEnv*)envhp, errhp, spoolhp,
(text **)&poolName, (ub4*)
&poolNameLen,
(OraText *)target_db, (sb4)strlen
((const char *)target_db),
connMin, connMax, connInc,
(text*) username, (ub4) strlen
((char *)username),
(text *) passwd, (ub4) strlen
((char *)passwd),
OCI_SPC_STMTCACHE
);
printf("1.3 errno = %s\n", strerror(errno));
printf("status OCISessionPoolCreate%d\n",status);
status = OCISessionGet((OCIEnv*) envhp, (OCIError*)errhp, (OCISvcCtx**)&svchp, NULL,
(text *) poolName,
(ub4) poolNameLen,
NULL, 0, NULL, 0, NULL,
OCI_SESSGET_SPOOL);
//OCIErrorGet ( err, (ub4) 1, (text *) NULL, &errcode,
// errbuf, (ub4) sizeof(errbuf), (ub4) OCI_HTYPE_ERROR);
// printf("Error - %s\n", errbuf);
printf("1.4 errno = %s\n, errhp = %i\n", strerror(errno), errhp);
printf("status OCISessionGet%d, i = %d \n\n\n",status, i);
usleep(1000);
}
return 0;
} |
Partager