test.pc
#include
#include "sqlca.h"
int connect_db( char *_dbname )
{
char sdb_name[60+1];
EXEC SQL BEGIN DECLARE SECTION;
char dbname[20+1];
cha r username[20+1];
char password[20+1];
EXEC SQL END DECLARE SECTION;
memset( dbname, 0x00, sizeof(dbname) );
memset( username, 0x00, sizeof(username) );
memset( password, 0x00, sizeof(password) );
sprintf( sdb_name, "%.60s", _dbname );
strcpy( username, strtok(sdb_name, "/") );
strcpy( password, strtok(NULL, "@") );
strcpy( dbname, strtok(NULL, "@") );
EXEC SQL CONNECT :username IDENTIFIED BY :password USING :dbname;
if( sqlca.sqlcode )
{
return -1;
}
return 0;
}
int main()
{
int ret=0;
ret = connect_db();
if (ret)
{
printf("Connect ERROR\n");
}
else
{
printf("Connect SUCCESS !!!\n");
}
return 0;
}
==========================
makefile
=========================
.SUFFIXES: .pc .c .o
.c.o:
$(CC) -c $(DFLAG) $(INCL) $<
.pc.o:
#$(PROC) $(INCL_PC) $(PROCFLAGS) iname=$<
$(PROC) $(INCL_PC) iname=$<
$(CC) -g -c $(DFLAG) $(INCL) $*.c
@-rm -f $*.c
@-rm -f $*.lis
VPATH=..:.
BINDIR= ../../bin
LIBDIR= ../../lib
LIB= -L$(LIBDIR) -L$(ORACLE_HOME)/lib -lclntsh
INCL_PC= include=/usr/include \
include=$(ORACLE_HOME)/precomp/public \
DFLAG= -q64 -DORACLE
INCL= -I../../include -I$(ORACLE_HOME)/precomp/public -I$(ORACLE_HOME)/rdbms/public
PROC=proc
CC=cc -q64
OBJT=test.o
all: clear test
clear:
@rm -f *.c
@rm -f *.lis
@rm -f *.o
test:$(OBJT)
$(CC) -o $@ $(?) $(LIB)
@chmod a+x $@
@echo "\033[7m Load $@ Successful!! \033[27m"
$@ ../../bin
@rm $?
=======================================================
阅读(536) | 评论(0) | 转发(0) |