안녕하세요 강남구 입니다.... solaris 9 x86 버전에서 cpre 를
이용하여서 sybase 에 insert 를 시키려고 합니다....(소스는 밑쪽에
있습니다.)
근데 커넥션 부분에서 에러가 발생하네요.. 고수님들의 조언
부탁드립니다...
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
/opt/sybase/OCS-12_5/bin/cpre -C KR_C -m -DSYBASE bbb.cp
cc -g -c -I. -I/opt/sybase/OCS-12_5/include bbb.c
cc -g -o bbb bbb.o -L/opt/sybase/OCS-12_5/lib -lct -lcs -ltcl
-lcomn -lintl -Bdynamic -lnsl -ldl -lm -L/usr/lib -lnsl -lsocket
-lresolv
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
위와 같은 컴파일 과정을 거쳐서 나온 bbb 파일을 실행한
결과 ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
insert into tbl_bs_proc_config(ess_type,switch_id,proc_name)
values(10,'abce','qweq')
DB CONNECT 실패, user=sa, password=sybase SQLCODE = -101188867
!
DB CONNECT 실패, user=sa, password=sybase SQLCODE = -101188867
!
DB CONNECT 실패, user=sa, password=sybase SQLCODE = -101188867
!
DB CONNECT 실패, user=sa, password=sybase SQLCODE = -101188867
!
...DB CONNECT
ERROR ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
이렇게 뜨고 커넥션을 못하는 상태 입니다....
EXEC SQL INCLUDE SQLCA;
#include <stdio.h>
#include <time.h>
#include <memory.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/varargs.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <sybhesql.h>
#include <sybtesql.h>
#include <sqlca.h>
#include <sqlda.h>
#define SQLCODE sqlca.sqlcode
#define SQLNOTFOUND 100
#define DB_SQL_ERROR 200
#define SQL_ALREADY_EXIST -2601
#define SQL_DATA_NULL -1
#define OK 0
#define NOK -1
int iDBConnect()
{
EXEC SQL BEGIN DECLARE SECTION;
char user[10];
char password[10];
char dbname[10];
char server_name[30];
EXEC SQL END DECLARE SECTION;
strcpy(user,"sa");
strcpy(password,"sybase");
strcpy(dbname,"emove");
strcpy(server_name,"-N vmSparc");
SQLCODE = 0 ;
EXEC SQL CONNECT :user IDENTIFIED BY :password USING
:server_name;
if( SQLCODE < 0 ) {
printf("DB CONNECT 실패, user=%s,
password=%s SQLCODE = %d !\n", user, password, SQLCODE );
return( NOK ) ;
}
EXEC SQL USE :dbname ;
if( SQLCODE < 0 ) {
printf("DB USE 실패, dbname=%s SQLCODE = %d
!\n", dbname, SQLCODE );
return( NOK ) ;
}
return( OK ) ;
}
void
vDBDisconnect()
{
EXEC SQL DISCONNECT ALL;
if( SQLCODE < 0 ) {
printf("DB DISCONNECT 실패SQLCODE = %d !\n", SQLCODE );
}
}
void main(void)
{
EXEC SQL BEGIN DECLARE SECTION;
char sqlstring[600];
EXEC SQL END DECLARE SECTION;
int ess_type=10;
char switch_id[10];
char proc_name[5];
strcpy(switch_id,"abcd");
strcpy(proc_name,"qwer");
int itry=0;
sprintf(sqlstring, "insert into
tbl_bs_proc_config(ess_type,switch_id,proc_name)
values(%d,\'%s\',\'%s\')",ess_type,switch_id,proc_name);
while(iDBConnect() != OK)
{
if(itry < 3)
{
sleep(1);
itry++;
}
else
{
printf("...DB CONNECT ERROR \n");
exit(-1);
}
}
printf("Connection successful!!!!!!!!");
EXEC SQL PREPARE insert_statement FROM :sqlstring;
EXEC SQL EXECUTE insert_statement;
EXEC SQL COMMIT;
vDBDisconnect();
}
|