0

I'm trying to connect to oracle DB on remote server:

userid = getenv("ORACLE_USER");
oracle_password  = getenv("ORACLE_USER_PASSWORD");
db_name = getenv("DB_NAME");

EXEC SQL CONNECT :userid IDENTIFIED BY :oracle_password USING :db_name;

I get an error: ORA-01034.

I'd be happy for help. Thanks.

Refael
  • 6,753
  • 9
  • 35
  • 54
  • [Oracle is not running](http://www.dba-oracle.com/sf_ora_01034_oracle_not_available.htm). Did you even try searching for the error code? – Jonathon Reinhart Oct 10 '13 at 07:34
  • Certainly. I checked all my parameters are set correctly. – Refael Oct 10 '13 at 07:38
  • 1
    possible duplicate of [How to connect to Oracle 11g database remotely](http://stackoverflow.com/questions/8108320/how-to-connect-to-oracle-11g-database-remotely) – durron597 Sep 05 '15 at 20:34
  • See if my answer [>here<](https://stackoverflow.com/questions/8108320/how-to-connect-to-oracle-11g-database-remotely/32416339#32416339 ">Here<") helps – Tony Sep 05 '15 at 18:26

3 Answers3

0
EXEC SQL BEGIN DECLARE SECTION; 
userid VARCHAR(50);
oracle_password VARCHAR(50);
db_name VARCHAR(50);
EXEC SQL  END DECLARE SECTION; 
main()
{
userid.arr = getenv("ORACLE_USER");
userid.len = strlen(userid.arr);
oracle_password.arr  = getenv("ORACLE_USER_PASSWORD");
oracle_password.len = strlen(oracle_password.arr);
db_name.arr = getenv("DB_NAME");
db_name.len = strlen(db_name.arr);
EXEC SQL CONNECT :userid IDENTIFIED BY :oracle_password USING :db_name;
if (sqlca.sqlcode==0)
{
prnitf("sucessful");
}
else
{
printf("failed");
return;
}
}

Hope it may be useful to you.

0

You will get ORA-01034 error when the database was not started up.

Possible causes include the following:

  • The SGA requires more space than was allocated for it.

  • The operating-system variable pointing to the instance is improperly defined.

Following line may resolve you issues

Check out link

0

First of all, use the alternative format: EXEC SQL CONNECT :usr_pwd; where the host variable usr_pwd contains your username and password separated by a slash character (/).

Then for usr_pwd attach remote server info: "user/pwd@(DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = xx.xx.xx.xx)(PORT = xxxx)))(CONNECT_DATA = (SERVICE_NAME = xxxxx)))"

For fast verification, you can use sqlplus to see if it connects first then plug in your code and compile: sqlplus user/pwd@(DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = xx.xx.xx.xx)(PORT = xxxx)))(CONNECT_DATA = (SERVICE_NAME = xxxxx)))

Feng Zhang
  • 1,698
  • 1
  • 17
  • 20