首先说明,PHP官方手册就有解决方案,只是不太好找。
遇到问题:
oracle服务器只支持sid的方式连接,在sqldevelpoer里面连接的时候,不能选服务,只能选sid。
选服务报ora-12514错误。
PHP连接,通常使用手册中说明的的easyconnect串的方式连接,如:
192.168.1.1:1521/orcl如果是支持SID连接的时候,就会报错,Ora-12514。
解决方案:
[#zeyu#]
PHP手册中,对connect_string有这样的描述,
包含要连接的 Oracle 实例
。可以是 » Easy Connect 串,或是 tnsnames.ora 文件中的连接名,或是本地 Oracle 实例名。
在手册评论中,接近末尾为一段话:
I started getting "ORA-12514: TNS:listener does not currently know of service requested in connect descriptor" errors when I upgraded my database instance from 10.2 to 11.2. For some reason it would not resolve the oci_connect calls with the Easy Connect syntax (easy connect calls from sqlplus were fine). I was able to workaround the issue by passing a tns connect string: <?php $db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.XX.XXX)(PORT = 1521)))(CONNECT_DATA=(SID=XXXX)))"; $c1 = oci_connect("name","password",$db); ?>
[/#zeyu#]
------------正 文 已 结 束, 感 谢 您 的 阅 读 (折雨的天空)--------------------
转载请注明本文标题和链接:《PHP连接Oracle,服务器只支持SID时,报ora-12514错误的解决》
发表评论