Skip to content

DBAL-60: OCI8Connection couldn't connect when charset parameter specified #1813

Closed
doctrinebot opened this Issue Nov 9, 2010 · 5 comments

2 participants

@doctrinebot

Jira issue originally created by user adrive:

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:

{quote}
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
{quote}

There is bug in OCI8Connection::errorInfo() and ::errorCode(). When ociconnect 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:

{quote}
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
{quote}

That's because ociconnect 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.

@doctrinebot

Comment created by @beberlei:

Fixed

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot

Comment created by userua:

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

@doctrinebot

Comment created by adrive:

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

@doctrinebot doctrinebot added the Bug label Dec 7, 2015
@beberlei beberlei was assigned by doctrinebot Dec 7, 2015
@doctrinebot doctrinebot added this to the 2.0.0-RC1-RC3 milestone Dec 7, 2015
@doctrinebot doctrinebot closed this Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.