Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> oracle db connection problem
Hi,
I have written a simple C script with embedded sql to connect to a
database server. There is no compilation errors/warnings after using the
Pro C/C++ precompiler and the corresponding make file.
I get the error :
ORA-12505: TNS:listener could not resolve SID given in connect descriptor
Could anyone help please ?? I have attached the code below. The version no is 8.0.5
Thanks,
Praveen
#include <stdio.h>
#include <string.h>
#include <sqlca.h>
main()
{
char username[10]= "dev1"; char password[10]= "dev1_TEST"; char db_string[10]="deveif8";
EXEC SQL WHENEVER SQLERROR DO error("Oracle error \n");
EXEC SQL DECLARE DB_NAME DATABASE;
printf("first line \n");
EXEC SQL CONNECT :username IDENTIFIED BY :password AT DB_NAME USING
:db_string;
printf("connected to oracle \n");
}
void error(msg)
char *msg;
{
char err_msg[128];
int 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);
exit(1);
}
Received on Thu Sep 16 1999 - 18:45:58 CDT
![]() |
![]() |