为什么我会收到此错误以及如何修复它?
我编写了一个 PHP 脚本来从 Oracle 数据库中提取查询并将结果写入 csv 文件。我正在使用 Zend Framework 连接到数据库。我知道凭据是正确的,因为我可以使用 SQLPlus 通过终端进行连接。
这是错误:
Zend_Db_Adapter_Exception: SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12514: TNS:listener 目前不知道连接描述符中请求的服务 (/home/http/php-5.3.3/ext/pdo_oci/ oci_driver.c:579) 在/opt/http/Zend/ZendFramework-1.10.3/library/Zend/Db/Adapter/Pdo/Abstract.php on line 144
我尝试过进行研究,但没有可靠的解决方案。我确实读到它可能与 tnsnames.ora 关联,但我在服务器上找不到该文件。我之前在其他项目中使用过 Zend,没有任何问题。
仅供参考:我没有root权限,所以我不能在服务器上做太多的事情。
您有什么建议?
I have written a PHP script to pull a query from an Oracle database and write results to a csv file. I am using Zend Framework to get connected to the database. I know the credentials are correct as I am able to connect through terminal using SQLPlus.
This is the error:
Zend_Db_Adapter_Exception: SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor (/home/http/php-5.3.3/ext/pdo_oci/oci_driver.c:579) in /opt/http/Zend/ZendFramework-1.10.3/library/Zend/Db/Adapter/Pdo/Abstract.php on line 144
I have tried to do research, but no solid solutions. I did read that it could be associated with the tnsnames.ora but I couldn't find that file on the server. I have used Zend before in other projects without any issues.
FYI: I do not have root, so I can't do much magic on the server.
What are your suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要在
$ORACLE_HOME/network/admin
文件夹中创建一个名为 tnsnames.ora 的文件,并将您的 SID 放入其中。或者,如果您无法创建 tnsnames.ora,请尝试使用以下语法设置数据库配置:
尽管最好使用数据库配置创建 tnsnames.ora。
You need to create a file called tnsnames.ora in your
$ORACLE_HOME/network/admin
folder and put in it your SID .or if you can't create your tnsnames.ora, try setting your DB config using this syntax :
Althought its better to create tnsnames.ora with your DB config.
对于那些不使用 Zend Framework,但有类似问题的人,可以在 http://docs.php.net/manual/en/ref.pdo-oci.php#64756
如果您使用 SID 进行连接,请更改
为
For those not using Zend Framework, but having similar issue, a solution to this problem can be found on http://docs.php.net/manual/en/ref.pdo-oci.php#64756
If you're using SID to connect, change
to
这是来自 Oracle 的常见错误消息,与 zend 甚至 php 无关。我通常在 SQLDeveloper 或 Toad 中收到此消息。检查 tnsnames.ora、listener.ora、sqlnet.ora、日志文件等并尝试与客户端应用程序连接。 (如果还是不行,可以向管理员反馈)
That's a common errormessage from Oracle, there is nothing to do with zend or even php. I usually get this message in SQLDeveloper or Toad. Check the tnsnames.ora, listener.ora, sqlnet.ora, log files etc. and try to connect with a client app. (if it isn't working, you can report it to the admins)