简体   繁体   中英

Can connect through sqlplus but not through oci_connect (ORA-12154)

Using sqlplus user/pass@server I can successfully connect.

Using

$db='(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 1.2.3.4)(PORT = 1521)))(CONNECT_DATA = (SID = server)))';
$conn=oci_connect('user','pass',$db);

I can connect as well.

Howerver, using $conn=oci_connect('user', 'pass', 'server'); I can not. It drops the following error:

oci_connect(): ORA-12154: TNS:could not resolve the connect identifier specified

I had to manually create the directory $ORACLE_HOME/network/admin/ because the installation didn't do it. Then I created a tnsnames.ora in that directory with the content of the $db variable.

Where could be the problem?

this turned out to be a problem in the configuration of the DB. The DBA fixed it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM