[DBAL-141] PDO Connection Failure through TNS - PDOOracle/Driver.php line 56 Created: 01/Aug/11  Updated: 30/Oct/11  Resolved: 30/Oct/11

Status: Resolved
Project: Doctrine DBAL
Component/s: Platforms
Affects Version/s: 2.1
Fix Version/s: 2.2

Type: Bug Priority: Major
Reporter: Ed Anderson Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

CentOS 6.0, Symfony 2.0.0 (RC), PHP 5.3.6, Oracle 11g Enterprise, Oracle InstantClient 11.0.2


Issue Links:
Duplicate
is duplicated by DBAL-136 OCI8 Driver MUST support connections ... Resolved

 Description   

On line 56 of the file ./vendor/doctrine-dbal/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php:

The line reads:
$dsn .= '))(CONNECT_DATA=(SID=' . $params['dbname'] . ')))'; should read $dsn .= '))(CONNECT_DATA=(SERVICE_NAME=' . $params['dbname'] . ')))';

If both SID and SERVICE_NAME need to be available for use, then logic should be inserted to determine which method is being used.



 Comments   
Comment by Benjamin Eberlei [ 18/Aug/11 ]

Whats the difference? the Use of SID works for me.

Comment by Daniel Lima [ 18/Aug/11 ]

Hi Benjamin,

There are some Oracle connections that are setup from SERVICE_NAME (without a SID).
In my company we always use SERVICE_NAME to setup a connection and we needed to modify the OCI connection driver from Doctrine to works fine in our environment

Take a look in: http://stackoverflow.com/questions/43866/how-sid-is-different-from-service-name-in-oracle-tnsnames-ora

Comment by Ed Anderson [ 19/Aug/11 ]

There's a subtle difference between SID and SERVICE_NAME and I think the code should somehow account for the difference. Here's why... An SID points to a physical instance at the database level (Service Identifier). If you ask for a SID you only get one shot at the connection (and hopefully the database is up). That's the legacy method of connecting to Oracle.

However, for environments that have HA installations of Oracle using RAC, the SERVICE_NAME is what is used to point to a database instance (instead of a physical Service ID). If a given database instance is down and you're using SID - meaning you're looking to connect to a specific database, the connection fails. If you're in an environment with multiple instances of the target database, then RAC figures out where to send you if you're using SERVICE_NAME and you will land on an useable instance. This is the typical way to connect when Oracle is load-balanced and in a high-availability environment.

Comment by Benjamin Eberlei [ 04/Sep/11 ]

How can we solve this issue in a BC way? I wouldn't know if I can just change it the way suggested and it will work for everyone.

Comment by Benjamin Eberlei [ 30/Oct/11 ]

Fixed by adding a new parameter 'service' which has to be true to use SERVICE_NAME instead of SID.

Generated at Fri Jul 25 23:06:43 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.