Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Can't connect from C program (on AIX)
I can't even connect from a C program to an Oracle database under AIX; I get
a
segmentation fault as soon as the EXEC CONNECT is executed. My system
is:
AIX csg6000 2 4 000137834C00
Oracle 7.3.3
The program is actually a dumbed down version of one of the Oracle samples:
/* Define constants for VARCHAR lengths. */
#define UNAME_LEN 20 #define PWD_LEN 40
/* Declare variables. No declare section is
needed if MODE=ORACLE. */
VARCHAR username[UNAME_LEN]; /* VARCHAR is an Oracle-supplied struct */ varchar password[PWD_LEN]; /* varchar can be in lower case also. */
/* Include the SQL Communications Area.
You can use #include or EXEC SQL INCLUDE. */ EXEC SQL INCLUDE sqlca;
/* Declare error handling function. */
void sql_error();
main()
{
char temp_char[32];
/* Connect to ORACLE--
/* Set the length component of the VARCHAR. */
username.len = strlen((char *) username.arr);
/* Copy the password. */
strncpy((char *) password.arr, "TIGER", PWD_LEN); password.len = strlen((char *) password.arr);
/* Register sql_error() as the error handler. */
EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--\n");
/* Connect to ORACLE. Program will call sql_error()
printf("\nConnected to ORACLE as user: %s\n", username.arr);
printf("\nG'day.\n\n\n");
/* Disconnect from ORACLE. */
EXEC SQL COMMIT WORK RELEASE;
exit(0);
}
void
sql_error(msg)
char *msg;
{
char err_msg[128];
size_t buf_len, msg_len;
EXEC SQL WHENEVER SQLERROR CONTINUE;
printf("\n%s\n", msg);
buf_len = sizeof (err_msg);
sqlglm(err_msg, &buf_len, &msg_len);
printf("%.*s\n", msg_len, err_msg);
EXEC SQL ROLLBACK RELEASE;
exit(1);
}
== End of sample.pc ================================================
The program is compiled like this, without any warnings:
proc iname=sample.pc oname=sample.c include=. select_error=no \
userid=user/password sqlcheck=semantics code=ansi_c \ parse=full mode=oracle || /bin/rm -f sample.c cc -I. -g -c sample.c cc -o sample sample.o -L/home/app/oracle/product/7.3.3/lib \ -lclntsh
The program fails immediately. This is the run and stack trace:
Segmentation fault in reset_pthread_kill at 0xd03d4628 0xd03d4628 (reset_pthread_kill+0x38) 7ca6192e stwx r5,r6,r3 (dbx) t
reset_pthread_kill(??) at 0xd03d4628 sigaction(??, ??, ??) at 0xd03d5358 signal.signal(??, ??) at 0xd02d5518
upiini(??, ??, ??, ??) at 0xd0502ba0 upiah0(??, ??, ??, ??) at 0xd051a2ec sqllam(??, ??, ??, ??, ??, ??, ??, ??) at 0xd066ceb8 sqllo3t(??, ??, ??, ??, ??, ??, ??, ??) at 0xd066ca44 sqlcnt(??, ??, ??) at 0xd066b3e0 sqlexp(??, ??, ??, ??) at 0xd066bcf8
== End of stack trace ==============================================
Any hints are more than welcome. Please answer via e-mail as well as posting; my news server is VERY flaky.
Thanks,
--
Gonzalo A. Diethelm
gonzo_at_ing.puc.cl
Received on Thu Jun 04 1998 - 13:37:17 CDT
![]() |
![]() |