shorif2000
shorif2000

Reputation: 2654

php7 cannot connect to oracle pooled connection

this is working fine on cli and on a non pooled connection. when i try the following on cli it works

sqlplus CCP/"***"@DECCP1ST_POOLED.test.vis

but when i try to do this in php it throws an error

$c = oci_connect('CCP', "***", 'domain.com:33001/DECCP1ST_POOLED.test.vis');
print_r($c);

output is

Warning: oci_connect(): ORA-12514: TNS:listener does not currently know of service requested in connect descriptor in

in my tnsnames.ora i have

DECCP1ST_POOLED.test.vis =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = domain.com)(PORT = 33001))
    (CONNECT_DATA =
      (SERVER = POOLED)
      (SERVICE_NAME = DECCP1ST.test.vis)
    )
  )

I have followed this pdf. i have set oci8.connection_class = SHARED

Upvotes: 0

Views: 495

Answers (1)

timclutton
timclutton

Reputation: 13014

According to the PDF you linked in your question, page 15:

PHP applications must specify the server type POOLED in the connect string to use DRCP. Using Oracle’s Easy Connect syntax, the PHP call to connect to the sales database on myhost would look like:

$c = oci_pconnect('myuser', 'mypassword', 'myhost/sales:POOLED');

Based on the above, and your TNS string, you need to use the following in your script:

$c = oci_connect('CCP', '***', 'domain.com:33001/DECCP1ST.test.vis:POOLED');

It's important to note that you are using the Easy Connect syntax here so the TNSNAMES.ORA file is ignored. Because of this you must use the defined SERVICE_NAME (DECCP1ST.test.vis) not the TNS alias (DECCP1ST_POOLED.test.vis)!

Upvotes: 1

Related Questions