Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-60

OCI8Connection couldn't connect when charset parameter specified

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-BETA4
    • Fix Version/s: 2.0.0-RC1-RC3
    • Component/s: Drivers
    • Labels:
      None
    • Environment:
      PHP Version 5.3.3-1ubuntu9, OCI8 1.4.1, Oracle 10.2.0.4.0

      Description

      When I am trying to connect to Oracle instance with another charset then specified in my environment variable NLS_LANG I got an error.

      $connectionOptions['oracle'] = array(
          'driver' => 'oci8',
          'dbname' => 'BOOK',
          'user' => 'doctrine',
          'password' => 'doctrine',
          'charset' => 'AL32UTF8',
      );
      
      $em = EntityManager::create($connectionOptions['oracle'], $config, $evm);
      $em->getConnection()->connect();
      

      Produce error messages:

      PHP Warning: oci_error() expects parameter 1 to be resource, boolean given in /www/test/doctrine2/vendor/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php on line 149
      PHP Fatal error: Uncaught exception 'Doctrine\DBAL\Driver\OCI8\OCI8Exception' in /www/test/doctrine2/vendor/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php:42

      There is bug in OCI8Connection::errorInfo() and ::errorCode(). When oci_connect failed, it returns a boolean - false. but oci_error() accepts only resource as parameter. Therefor it is neccessary to check, whether $this->_dbh is resource.

      When I've fixed the error handling, I've got the right error, why I couldn't connect to Oracle:

      PHP Fatal error: Uncaught exception 'Doctrine\DBAL\Driver\OCI8\OCI8Exception' with message 'ORA-12154: TNS:could not resolve the connect identifier specified' in /www/test/doctrine2/vendor/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php:28

      That's because oci_connect accepts as connection string only TNS name, or Oracle Connection string. But ;charset=* in TNS name or connection string is invalid. oci_connect has 4th parameter charset for that purpose.

        Activity

        Miloslav "adrive" Kmet created issue -
        Show
        Miloslav "adrive" Kmet added a comment - Fixed in https://github.com/milokmet/dbal/tree/DBAL-60
        Hide
        Benjamin Eberlei added a comment -

        Fixed

        Show
        Benjamin Eberlei added a comment - Fixed
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0.0-RC1 [ 10094 ]
        Resolution Fixed [ 1 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 12083 ] jira-feedback2 [ 17670 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 17670 ] jira-feedback3 [ 20025 ]
        Hide
        Ruslan added a comment -

        Can you help me. I'm having same problem. But your link doesn't work.

        Show
        Ruslan added a comment - Can you help me. I'm having same problem. But your link doesn't work.
        Hide
        Miloslav "adrive" Kmet added a comment -

        You must have very old source code. The bug was fixed 2 years ago. Just compare your OCI8 driver with https://github.com/doctrine/dbal/tree/master/lib/Doctrine/DBAL/Driver/OCI8

        Show
        Miloslav "adrive" Kmet added a comment - You must have very old source code. The bug was fixed 2 years ago. Just compare your OCI8 driver with https://github.com/doctrine/dbal/tree/master/lib/Doctrine/DBAL/Driver/OCI8

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DBAL-60, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Miloslav "adrive" Kmet
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: