|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56362 Connection Error: TNS Error at "Protokolladapter"
Submitted: 2005-03-30 07:06 UTC Modified: 2005-04-04 04:47 UTC
From: jan-markus dot wilhelm at osram-os dot com Assigned:
Status: Closed Package: PDO_OCI (PECL)
PHP Version: 5.0.3 OS: Windows 2000 Advanced Server
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
26 - 7 = ?
Subscribe to this entry?

 [2005-03-30 07:06 UTC] jan-markus dot wilhelm at osram-os dot com
at first this is a great idea, PDO, congratulation. I found it as a solution for the Bug within the php_oci8 extension where a restart of the oracle db requires a restart of the apache webserver to be able to connect to the db again.

I am running:
Windows 2000 Advanced Server, Windows 2000 Server and Windows XP SP 2
Oracle and
Apache 2.0.53 and 2.0.52
PHP 5.0.3
PECL PDO: 0.3  	beta  	2005-03-09
PECL PDO OCI: 0.2  	beta  	2005-02-09
For this problem I downloaded an actual snapshot for PDO and PHP from 30.03.2005 10:00 AM CEST and tested it again.

I configured the PDO on my development machine and redesigned my PHP code for the PDO functions. Everything worked all right and was quite comfortable.
After this I commited the code to our testing environment and I received an error at the PDO constructor while connecting. I commited the code to our production environment and the same:

Dev: Windows XP SP2, Oracle, Apache 2.0.53
Test: Windows 2000 Server, Oracle, Apache 2.0.53
Prod: Windows 2000 Advanced Server, Oracle, Apache 2.0.52

That are the difference we do have between the systems. php.ini is absoluteley the same and http.conf either, expect of the server names and ips.

sqlplus does work with the same connection parameters and the oci extension is working fine (in general).
The only thing I can imagine is a missconfiguration within the connection parameters for the DB on my site but the error message therefor is not detailed enough and the source code of the oci_driver will either not tell me where this problem could come from.

from dev system i can connect to all oracle db installations, from test and prod i can connect to none of the others within the pdo.


phpinfo() extract, which is at all machines the same:
PDO support	enabled
PDO drivers 	oci

PDO Driver for OCI 8 and later	enabled

Best Regards Markus Wilhelm

Reproduce code:
$dbh = new PDO('oci:dbname', 'username', 'pw');

Expected result:
Expected result would be the connection object.

Actual result:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: 
pdo_oci_handle_factory: ORA-12560: TNS: Fehler bei Protokolladapter (..\pecl\pdo_oci\oci_driver.c:449)' in 

D:\programme\ApacheGroup\Apache2\htdocs\epos\pcn\test.php:3 Stack trace: #0 

PDO->__construct('oci:epos.osram....', 'epos_pcn', 'XXXX') #1 {main} thrown in 
D:\programme\ApacheGroup\Apache2\htdocs\epos\pcn\test.php on line 3


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-30 09:34 UTC] jan-markus dot wilhelm at osram-os dot com
Hi all,
well its getting strange.

I just rebooted my dev machine and tried to connect again to the production database (the dev db was down) and I received the same error in dev. Than I changed the DB, Username and PW strings arround and found out that independent of what I am writing as "oci:tnsnames_db" he will connect to the local installed oracle instance. This did not come up the last tests because the DBs are copies and the UN and PWs are the same on all three systems.

So for normal the tnsnames.ora looks like this: =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
      (SERVICE_NAME = oracle_service_name)

and the con string then looks like this:
$dbh = new PDO('', 'un', 'pw');

Is this correct for PDO?

BR Markus
 [2005-04-02 22:50 UTC] pete5520 at pdxeng dot com
I think I have the same issue, I'm on linux but I don't know German :)

my tnsnames.ora

the script
try {
$dbh = new PDO('oci:me','ppme','ppme');
} catch (PDOException $e) {
        // display warning message
        print $e->getMessage();
        $info = $e->errorInfo;
        // $info[0] == $e->code; unified error code
        // $info[1] is the driver specific error code
        // $info[2] is the driver specific error string
echo "\n";

running it php -f 

 php -f o
SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12162: TNS:net service name is incorrectly specified

I also get the same from a web page 

environment vars
[root@pdx7 wind]# echo $TNS_ADMIN
[root@pdx7 wind]# echo $ORACLE_HOME

tnsping, sqlplus work just fine
 [2005-04-02 23:31 UTC] pete5520 at pdxeng dot com
Well just my luck post a bug and figure out what I ! did

    $dbh = new PDO("oci:dbname=ppme", "ppme", "ppme");

seems to work
 [2005-04-04 04:47 UTC] jan-markus dot wilhelm at osram-os dot com
Hi all,
well I found the solution for the connection problem:

 $dbh = new PDO("oci:dbname=dbname;host=dbhost", "dbuser", "dbpass");

This is documented wrong in the PDO (OCI) Documentation. It seems that the PDO OCI does not use the tnsnames.ora a 100% correct or even does not use it at all.

    To connect via tnsnames.ora, use:

This problem described here occures only if the Oracle DB Server is listening to an IP other the localhost.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 05:01:28 2024 UTC