简体   繁体   English

可以通过sqlplus连接,但不能通过oci_connect连接(ORA-12154)

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

Using sqlplus user/pass@server I can successfully connect. 使用sqlplus user/pass@server可以成功连接。

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'); 但是,使用$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 oci_connect():ORA-12154:TNS:无法解析指定的连接标识符

I had to manually create the directory $ORACLE_HOME/network/admin/ because the installation didn't do it. 我必须手动创建目录$ ORACLE_HOME / network / admin /,因为安装没有执行该操作。 Then I created a tnsnames.ora in that directory with the content of the $db variable. 然后,我在该目录中使用$ db变量的内容创建了一个tnsnames.ora。

Where could be the problem? 问题可能出在哪里?

this turned out to be a problem in the configuration of the DB. 原来这是数据库配置中的问题。 The DBA fixed it. DBA修复了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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