php.net |  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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jan-markus dot wilhelm at osram-os dot com
New email:
PHP Version: OS:

 

 [2005-03-30 07:06 UTC] jan-markus dot wilhelm at osram-os dot com
Description:
------------
Hi,
at first this is a great idea, PDO, congratulation. I found it as a solution for the Bug within the php_oci8 extension http://bugs.php.net/bug.php?id=29779 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 9.2.0.5 and 9.2.0.4
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 9.2.0.4, Apache 2.0.53
Test: Windows 2000 Server, Oracle 9.2.0.5, Apache 2.0.53
Prod: Windows 2000 Advanced Server, Oracle 9.2.0.5, 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.

php.ini
extension=php_pdo.dll
extension=php_pdo_oci.dll 

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

PDO_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 

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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:
mydb.mydomain.com =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = oracle_service_name)
    )
  )


and the con string then looks like this:
$dbh = new PDO('oci:mydb.mydomain.com', '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
------------------------------------------------------------
PPME = (DESCRIPTION = 
(ADDRESS = (PROTOCOL = TCP)(HOST = sun3.pdxeng.com)
(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME=db1)))
------------------------------------------------------------

the script
<?php
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
 (/usr/local/src/PHP/PDO_OCI-0.2/oci_driver.c:416)

I also get the same from a web page 

environment vars
[root@pdx7 wind]# echo $TNS_ADMIN
/u01/app/oracle/OraHome_1/network/admin
[root@pdx7 wind]# echo $ORACLE_HOME
/u01/app/oracle/OraHome_1

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
wrong

    $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.

See: http://de.php.net/manual/de/function.pdo-construct.php
PDO_OCI
    To connect via tnsnames.ora, use:
    oci:mydb

This problem described here occures only if the Oracle DB Server is listening to an IP other the localhost.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Sep 21 17:01:27 2019 UTC