Saturday, March 15, 2014

When you forget to close database connections while coding server side scripting!!! - You forgot to give it closure!!!!

When you are in the initial stages of developing code either in JSP, PHP, Python etc., there might be chances that closing the connections can be forgotten. Especially we are just at the login page (the first stage of the project).

I did forget to close the connections!!! (a blunder) and after several testing... what did I get..


Then I checked the mysql database for maximum allowable connections


Maximum allowable is 151








If you see in the result above, there are several connections which are in Sleep which is because I didnt close the connections. Now one way is to kill atleast some of the processes






Viola!!!! Now I am able to get the Login page




If you can restart the OS, all the connections will be killed. See below, I have only one sleep process, rest all have been wiped out