Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Oracle8 : CONNECT to non-default database -> ORA-12154 (Server Error Message)
Hi,
///////////////////////////////////////////////1. Error message
I have got the following error message.
//===========================================
ORA-12154: TNS:could not resolve service name
in "..."
on line 97 of demo6.pc.
//===========================================
Here is a relevant piece of the code (Pro*C/C++).
What (and where) is wrong?
//===========================================
// file demo6.pc
void main()
{
/* Declare the program host variables. */
char *username = "aaa"; char *password = "bbb"; char *db_name = "ddd"; char *db_string = "NYNON"; asciz dynstmt1; char dynstmt2[10];
[ --- omitted --- ]
EXEC SQL CONNECT :username // Line#97 IDENTIFIED BY :password AT :db_name USING :db_string;puts("\nConnected to ORACLE.\n");
[ --- omitted --- ]
}
//===========================================
///////////////////////////////////////////////2. Questions
Here is a a piece from Oracle8 Documentation and my question.
### ### Single Explicit Connections ### ### In the following example, you connect to a single non-defaultdatabase at a
### remote node: ### ### /* declare needed host variables */ ### char username[10] = "scott"; ### char password[10] = "tiger"; ### char db_string[20] = "NYNON"; ### ### /* give the database connection a unique name */ ### EXEC SQL DECLARE DB_NAME DATABASE; ### ### /* connect to the non-default database */ ### EXEC SQL CONNECT :username IDENTIFIED BY :password ### AT DB_NAME USING :db_string; ### ### The identifiers in this example serve the following purposes: ### ### * The host variables username and password identify a valid user. ### * The host variable db_string contains the Net8 syntax for connecting to ### a non-default database at a remote node. In the example above db_string == "NYNON". 1. If db_string value is not arbitrary, what is this value connected with? 2. Is there any connection between db_string value (i.e. "NYNON") and the tnsnames.ora configuration file? 2. Is there any connection between db_string value (i.e. "NYNON") and another files? 4. What do I have to do yet to use db_string (== ""NYNON", for instance). ### * The undeclared identifier DB_NAME names a non-default connection; it is ### an identifier used by Oracle, not a host or program variable. ###
Thanks in advance, Alex
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Tue Oct 05 1999 - 07:07:40 CDT
![]() |
![]() |