pdo_oci_handle_factory: Error while trying to retr

2019-08-11 00:59发布

问题:

I'm using Laravel 5.5, php 7.1.9, and oracle 10g

i don't know if i'm connected to the database or not and if yes, is the problem in my code ?

PDOException SQLSTATE[HY000]: pdo_oci_handle_factory: Error while trying to retrieve text for error ORA-01804 (ext\pdo_oci\oci_driver.c:640)

oracledb.php

return [
    'oracle' => [
        'driver'    => 'pdo',
        'tns'       => env('DB_TNS', 'XE'),
        'host'      => env('DB_HOST', 'GREEN-PC'),
        'port'      => env('DB_PORT', '1521'),
        'database'  => env('DB_DATABASE', 'XE'),
        'username'  => env('DB_USERNAME', 'esprit'),
        'password'  => env('DB_PASSWORD', 'esprit'),
        'charset'   => '',
        'prefix'    => '',
        'quoting'   => false,
    ],
];

in my controller

public function show()
{
    $res =  DB::table('esp_etudiant')
        ->where('id_et','1630242')
    ->get();
    print_r($res);
}

回答1:

First, try connecting as SYSDBA.

$ sqlplus / as sysdba

There are several causes for the ORA-01804 error:

  • Check to make sure the following paths are set correctly in your environment:
$LD_LIBRARY_PATH 

$ORACLE_HOME 

$NLS_LANG
  • Your oracle client may be missing some timezone dat files in the $ORACLE_HOME directory. You should have a separate ORACLE_HOME for each release of Oracle. If this is the case, then :

The first thing to do is to check if ORA_TZFILE is set and if it is, remove it and restart the database and listener. Oracle will then try to load the $ORACLE_HOME/oracore/zoneinfo/timezlrg.dat file.

If for some reason the file that Oracle wants to use is not available then this is the cause of the problem.

If the file is present then an alternative reason for the error could be that Oracle cannot load the file because of permission problems.

If all above is correct then it might be a .dat file that is corrupt.

  • Check that the permissions are set to allow reads (chmod 444) for the files in the OCCI library.