Laravel不与Oracle建立联系

时间:2015-01-10 10:37:43

标签: php laravel laravel-4 oracle11g oracle-sqldeveloper

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

显示此错误: enter image description here

我在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
  ),

但是我和Sql Developer有联系。 请参阅Sql-Developer属性:enter image description here

3 个答案:

答案 0 :(得分:0)

此行中的问题:'database' => 'ocp' ,'database' => 'orcl' ,

解决它

'database'=> '192.168.152.189/orcl'

答案 1 :(得分:0)

试试这个

'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' => '',
),

答案 2 :(得分:0)

尽管此问题已在将近三年后发布... 但是我只是用这种方式解决这个问题

在oracle中搜索此命令

Select instance_name from v$instance;

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