Reputation: 50
I'm trying to connect to the oracle database of a new partner, 11g Release 11.2.0.4.0, and I'm receiving the following error:
Warning: oci_connect(): ORA-12545: Connect failed because target host or object does not exist
The partner affirms that the connection string provided is correct.
This is the current structure of mine oci_connect() and the said connection string being used:
$connection_string = '(DESCRIPTION = (ADDRESS_LIST = (LOAD_BALANCE = ON)(FAILOVER = ON)(ADDRESS = (PROTOCOL = TCP)(HOST = HOST)(PORT = 1521)))(CONNECT_DATA = (SERVICE_NAME = SERVICE_NAME)))'
$conn = oci_connect($username, $password, $connection_string, 'UTF8', OCI_DEFAULT);
But, when using the following structure:
$connection_string = 'user/password@host:port/service_name'
$conn = oci_connect($username, $password, $connection_string, 'UTF8', OCI_DEFAULT);
It returns:
Warning: oci_connect(): ORA-12154: TNS:could not resolve the connect identifier specified
To give a clear picture of what I did, below are the steps I took to create my App-Service and install the oci8 php driver:
After that I could confirm the existence of the oci8 extension on my phpinfo() page.
Those steps where made following this documentation: Azure App Service Linux - Adding PHP Extensions
I also have latter defined the ORACLE_HOME setting as being /home/site/oracle/instantclient_18_5, but it had no diferences.
I'm out of ideas, can someone please indicate me what could be causing this problem and how can I solve it.
EDIT:
After further conversations with the partner it becamed clear that there isn't no way for me to connect to their database considering the current configuration of the same. As noted int the comments by Christopher Jones, its a problem of networking, ORA-12545, ORA-12541, ORA-12514, & ORA-01017 – How to fix for SQL Developer, and, in this case, lack of proper feedback.
Upvotes: 1
Views: 1449
Reputation: 196
Ok,
So I fought with this for a long time and could never get it to find the tnsnames.ora file no matter what I did. Finally I decided to pull the connection string definition out of the tnsnames.ora file and insert it directly into the oci_connect statement as the connection string and it worked:
//$connection_string = '(DESCRIPTION = (ADDRESS_LIST = (LOAD_BALANCE = ON)(FAILOVER = ON)(ADDRESS = (PROTOCOL = TCP)(HOST = HOST)(PORT = 1521)))(CONNECT_DATA = (SERVICE_NAME = SERVICE_NAME)))'
$connection_string = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.10)(PORT=1521))(CONNECT_DATA=(SERVER = DEDICATED)(SERVICE_NAME = pdb_mypdb.xyz.com)))';
$conn = oci_connect("mypdb", "mypdbpw", $connection_string );
What is even more cool is that in a lot of third-party programs, when they ask for the name of the oracle server, you can put the ENTIRE tnsnames.ora CONNECT definition (like above, in $connection_string) in to the "server name" and it will work. You don't even need tnsnames.ora, etc. and all the load-balancing, etc., will all work.
Good luck, David
Upvotes: 0