How to close db oracle connection with php on Apache server? I mean close immediately

Closing a connection is usually done simply, oci_close($connection);

or in the worst case, when the PHP script ends the connection.

In my case, however, I run into a different behavior.

If I access my application that uses PHP 5.2.8, Apache 2.2.11 and oci8 1.2.5, the connection persists for a few minutes.

It actually looks like this: if I run netstat -b

, I see that the process httpd.exe

remains in a state ESTABLISHED

to the database url for some time (several minutes).

Can anyone enlighten me on this behavior?

PS I am not using persistent connections.

PPS How the code used to connect and close is set here (this is a legacy app):

connection: a function is called whose associated code is $connection = @ocilogon ( "$username", "$password", "$database" );

closure: the responsibility of every page we develop, but usually it will oci_close($connection)

+2


a source to share


1 answer


In the docs on oci_connect()

here ( ocilogon()

calls the same function):

http://www.php.net/manual/en/oci8.connection.php

This means that you can close the connection explicitly via, oci_close()

or automatically close it at the end of the displayed page. I would suggest that if you don't close explicitly that it might take a while for the timeout. Is it possible that some pages with no calls oci_close()

are causing the open connections you see?



If you create a separate page with just oci_connect()

and oci_close()

and then execute it a few times, you can see that the number of connections increases directly, how many times have you executed the page and did not return before going down?

Also, on which indicator do you see that the connection remains open?

if you were on higher versions then it might be Oracle 11g Database Resident Connection Pooling, but that doesn't exist in your current versions you are using.

0


a source







All Articles