onunix 2012-06-21 18:03:37 8970次浏览 4条回复 0 0 0

Yii连接oracle 11g r2数据库,报错。

main.php

'connectionString' =>'oci:dbname=172.30.1.39:1521/orcl',
'username' => 'root',
'password' => 'a'
),

CDbException

CDbConnection 无法开启数据库连线: SQLSTATE[]: pdo_oci_handle_factory: <<Unknown>> (ext\pdo_oci\oci_driver.c:579) 

D:\skill\finance\yii-1.1.10.r3566\framework\db\CDbConnection.php(382)

370                 throw new CDbException(Yii::t('yii','CDbConnection.connectionString cannot be empty.'));
371             try
372             {
373                 Yii::trace('Opening DB connection','system.db.CDbConnection');
374                 $this->_pdo=$this->createPdoInstance();
375                 $this->initConnection($this->_pdo);
376                 $this->_active=true;
377             }
378             catch(PDOException $e)
379             {
380                 if(YII_DEBUG)
381                 {
382                     throw new CDbException(Yii::t('yii','CDbConnection failed to open the DB connection: {error}',
383                         array('{error}'=>$e->getMessage())),(int)$e->getCode(),$e->errorInfo);
384                 }
385                 else
386                 {
387                     Yii::log($e->getMessage(),CLogger::LEVEL_ERROR,'exception.CDbException');
388                     throw new CDbException(Yii::t('yii','CDbConnection failed to open the DB connection.'),(int)$e->getCode(),$e->errorInfo);
389                 }
390             }
391         }
392     }
393 
394     /**
Stack Trace
#0  +– D:\skill\finance\yii-1.1.10.r3566\framework\db\CDbConnection.php(331): CDbConnection->open() 

请问这是什么原因呢?

  • 回复于 2012-06-28 15:31 举报

    请问有使用oracle 11g r2 windows 64位的么?Yii能连上去么?

  • 回复于 2012-06-28 15:54 举报

    改成

    'db'=>array(
    'class'=>'CDbConnection',
    'connectionString' => 'oci:dbname=172.30.1.39:1521/orcl;charset=utf8',
    'emulatePrepare' => true,
    'username' => 'imp',
    'password' => 'aa'
    ), 
    

    错误提示:

    CDbConnection 无法开启数据库连线: SQLSTATE[HY000]: OCIEnvNlsCreate: Check the character set is valid and that PHP has access to Oracle libraries and NLS data (ext\pdo_oci\oci_driver.c:558) 
    
    D:\skill\finance\yii-1.1.10.r3566\framework\db\CDbConnection.php(382)
    
    370                 throw new CDbException(Yii::t('yii','CDbConnection.connectionString cannot be empty.'));
    371             try
    372             {
    373                 Yii::trace('Opening DB connection','system.db.CDbConnection');
    374                 $this->_pdo=$this->createPdoInstance();
    375                 $this->initConnection($this->_pdo);
    376                 $this->_active=true;
    377             }
    378             catch(PDOException $e)
    379             {
    380                 if(YII_DEBUG)
    381                 {
    382                     throw new CDbException(Yii::t('yii','CDbConnection failed to open the DB connection: {error}',
    
  • 回复于 2012-07-02 10:07 举报

    似乎没有人使用oracle数据库

  • 回复于 2012-07-11 18:47 举报

    连接ORACLE 有3种方式 THIN JDBC 和 OCI方式 PHP连接ORACLE是以OCI连接的

    首先要开启PHP.INI里相关
    extension=php_pdo_oci.dll
    extension=php_pdo_oci8.dll
    这2个扩展 然后要确保你的PHP目录下有此DLL文件!

您需要登录后才可以回复。登录 | 立即注册