Re: ERROR ORA-12154 TNS: could not resolve the connect identifier specified

From: <sybrandb_at_hccnet.nl>
Date: Tue, 14 Oct 2008 18:32:47 +0200
Message-ID: <m4i9f4ddmo3752641q00cdcu72iv7gj92b@4ax.com>


On Mon, 13 Oct 2008 11:24:17 -0700 (PDT), beta <qlng2000_at_gmail.com> wrote:

>Hi,
>
>I have a strange problem with oracle connection. It gives a "ERROR
>ORA-12154 TNS: could not resolve the connect identifier specified"
>srror on the browser.
>
>Here is my oraConnect.php ##############
><?php
> $conn = OCILogon("hr", "hr", 'demo');
> $query = 'select * from hr.jobs';
>
> $stid = OCIParse($conn, $query);
> OCIExecute($stid, OCI_DEFAULT);
> while ($succ = OCIFetchInto($stid, $row)) {
> foreach ($row as $item) {
> echo $item." ";
> }
> echo "<br>\n";
> }
>?>
>
>#### OUT put
># php oraConnect.php
>AD_PRES President 20000 40000 <br>
>AD_VP Administration Vice President 15000 30000 <br>
>AD_ASST Administration Assistant 3000 6000 <br>
>FI_MGR Finance Manager 8200 16000 <br>
>FI_ACCOUNT Accountant 4200 9000 <br>
>AC_MGR Accounting Manager 8200 16000 <br>
>AC_ACCOUNT Public Accountant 4200 9000 <br>
>SA_MAN Sales Manager 10000 20000 <br>
>
>### TNSNAME / tnsping
># tnsping demo
>
>TNS Ping Utility for Linux: Version 11.1.0.6.0 - Production on 13-
>OCT-2008 11:20:30
>
>Copyright (c) 1997, 2007, Oracle. All rights reserved.
>
>Used parameter files:
>/u01/app/oracle/product/11.1.0/db_1/network/admin/sqlnet.ora
>
>
>Used TNSNAMES adapter to resolve the alias
>Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST
>= xxx.xxxx.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED)
>(SERVICE_NAME = demo)))
>OK (0 msec)
>
>#### browser
>http://localhost/oraConnect.php
>Warning: ocilogon() [function.ocilogon]: ORA-12154: TNS:could not
>resolve the connect identifier specified in /opt/www/oraConnect.php on
>line 2
>
>Warning: ociparse() expects parameter 1 to be resource, boolean given
>in /opt/www/oraConnect.php on line 5
>
>Warning: ociexecute() expects parameter 1 to be resource, null given
>in /opt/www/oraConnect.php on line 6
>
>Warning: ocifetchinto() expects parameter 1 to be resource, null given
>in /opt/www/oraConnect.php on line 7
>
>
>Thanks mycn,
>Beta
>
>

Stupid questions maybe, but anyway questions about this error are always redundant as there is a plethora of resources, just *because* people don't do anything to resolve it themselves:

Is the webserver located on the database server? Did you run tnsping on the webserver or on the database server? Do you have one or multiple tnsnames.ora floating around? Did you set the TNS_ADMIN enviroment variable? Please note similar questions have been asked to other people with the same problem, so I have one final question: Why didn't you bother to search the documentation or forums.oracle.com or Usenet. Assum ing you are unioue? Or just lazy? Just wondering...

-- 
Sybrand Bakker
Senior Oracle DBA
Received on Tue Oct 14 2008 - 11:32:47 CDT

Original text of this message