Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
cancel
Showing results for 
Search instead for 
Did you mean: 

Pro*c can't logon remote host

SOLVED
Go to solution
zhaokai_1
Occasional Advisor

Pro*c can't logon remote host

Hi everyone!
I got a problem while writing a ".pc" file to obtain access to a remote oracle database.
The connection part of the program is :
" EXEC SQL BEGIN DECLARE SECTION;
char username[20];
char password[20];
char db_string[20];
EXEC SQL END DECLARE SECTION;
EXEC SQL DECLARE db_name DATABASE;
strcpy(username,"system");
strcpy(password,"******");
strcpy(db_string,"oracle");
EXEC SQL WHENEVER SQLERROR DO sqlerror();
EXEC SQL CONNECT:username IDENTIFIED
BY:password AT db_name USING:
db_string;
printf("\nConnected to ORACLE as user:%s\n",username);"
When I excute the program,I encountered the following error:"oracle error detected:
ora-01012:not logged on"
How can i settle the problem?
Thanks in advance!

6 REPLIES
Jean-Luc Oudart
Honored Contributor

Re: Pro*c can't logon remote host

Hi

to check the environment, could you run a sqlplus session with same parameters (username, password, connect string) ?

Regards
Jean-Luc
fiat lux
zhaokai_1
Occasional Advisor

Re: Pro*c can't logon remote host

Thanks for your advice.
But how can i organize the connect string?
For example,using the db_name and db_string?
Yogeeraj_1
Honored Contributor
Solution

Re: Pro*c can't logon remote host

hi,

have a look this example:

main( argc, argv )
int argc;
char * argv[];
{
EXEC SQL BEGIN DECLARE SECTION;
varchar oracleid[31];
int x;
EXEC SQL END DECLARE SECTION;

strcpy( oracleid.arr, "scott/tiger@mydb" );
oracleid.len = strlen(oracleid.arr);

EXEC SQL WHENEVER SQLERROR DO sqlerror_hard();
EXEC SQL CONNECT :oracleid;
printf("\nConnected to ORACLE as user: %s\n\n", oracleid.arr);

x = really_complex_calculation();

exec sql insert into xx ( x ) values ( :x );

/* Disconnect from ORACLE. */
/* EXEC SQL COMMIT WORK RELEASE; */
exit(0);
}

hope this helps!
regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
zhaokai_1
Occasional Advisor

Re: Pro*c can't logon remote host

Thanks very much
I saw the "CONNECT:...IDENTIFIED BY:...
AT:... USING:..." way to logon to a remote host from a book,but don't know exactly how to use it.Your method looks easier and it does works.
Yogeeraj_1
Honored Contributor

Re: Pro*c can't logon remote host

hi again,

have a look also at the "Connect to the Database" section at the following URL:
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a97269/pc_03dbc.htm#5881

hope this helps too!

regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Jean-Luc Oudart
Honored Contributor

Re: Pro*c can't logon remote host

Hi

db_string is the host variable that constains the NET8 syntax for connecting to a non-default database on a remote node.

I meant to use the sqlplus utility to validate your environment, especially the db_string.

Check and validate your tnsnames.ora.

sqlplus system/@

Regards
Jean-Luc
fiat lux