Laravel 无法与 Oracle 连接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27875241/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 10:40:18  来源:igfitidea点击:

Laravel dosen't connect with Oracle

phplaravellaravel-4oracle11goracle-sqldeveloper

提问by Anowar Hossain

I'm using yajra/laravel-oci8for Oracle connection with laravel. But I couldn't connected to Oracle, from my client PC to Server.

我将 yajra/laravel-oci8用于 Oracle 与 laravel 的连接。但是我无法连接到 Oracle,从我的客户端 PC 到服务器。

showing this error: enter image description here

显示此错误: 在此处输入图片说明

I'm using this code in database.php:

我在 database.php 中使用此代码:

'oracle' => array(
       'driver' => 'oracle',
       'host' => '192.168.152.189',// this is my server IP
       'port' => '1521',
       'database' => 'ocp',
       'username' => 'ocpl',
       'password' => '123456',
       'charset' => 'AL32UTF8',
       'prefix' => '',
       'port' => 1521
  ),

But I'm connected with Sql Developer. see the Sql-Developer Property: enter image description here

但我与 Sql Developer 有联系。请参阅 Sql-Developer 属性:在此处输入图片说明

回答by Md. Jahir Alam Raju

problem in this line : 'database' => 'ocp' ,solve it with : 'database' => 'orcl' ,or

这一行的问题: 'database' => 'ocp' ,解决它: 'database' => 'orcl' ,

'database' => '192.168.152.189/orcl'

'数据库' => '192.168.152.189/orcl'

回答by RANJITH

Try this

尝试这个

'oracle' => array(
       'driver' => 'oracle',
       'tns' => '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.152.189)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))',
       //'host' => '192.168.152.189',// this is my server IP
       //'port' => '1521',
       'database' => '',
       'username' => 'ocpl',
       'password' => '123456',
       'charset' => 'AL32UTF8',
       'prefix' => '',
),

回答by W Kenny

Although this question has been posted after almost three year... but I just use this way to solve this problem

虽然这个问题在将近三年后才被贴出来......但我只是用这种方式来解决这个问题

search this command in oracle

在 oracle 中搜索此命令

Select instance_name from v$instance;

then paste the value into 'database' setting

然后将该值粘贴到“数据库”设置中