Feb 22nd, 2013, 12:11 PM
Releasing database connections
I apologize this might not be clear as I have a sysadmin background/role and am trying to ramp up on spring development.
Our production site seems to have an issue where when an Exception occurs in one of our controllers, the c3p0 connection that was being used by the user hitting the controller is not released. I get the feeling that even if we were using another connection pool technology or no pool that this would cause an issue.
My impression about Spring is that one of the benefits is that you don't have to worry about creating/releasing connections to your database. Is this correct? Any ideas why this could be happening?
Somehow, this scenario loops or goes out of control and depletes all connection in the Tomcat's connection pool which is obviously not desirable behavior.
Any suggestions would be greatly appreciated!
Feb 22nd, 2013, 01:16 PM
My guess wrong transaction setup or open connection outside of springs transaction management.
For spring to manage your resources it needs transactions and a proper transaction configuration. Without those your connection pool will deplete .
Feb 25th, 2013, 09:09 AM
I'm starting to wonder if we are doing what you are mentioning as I've just found a scenario where i can prove we are leaking a connection and can deplete our connection pool. Problem is, my java/Springs background is not too strong yet and I'm not sure where to start looking.
Right now, i have eclipse connected to a test database and am trying to see through stepping through code if I could see where it opens but doesn't close.
Any example for what you said above that might help me understand what to look for?
Feb 25th, 2013, 12:37 PM
And to add to the above, when i monitor my jmx numBusyConnections and I have a breakpoint in my code, it will never leak a connection even if i click "furiously" on the next button that creates this leak but If I remove my breakpoint and click furiously, then i leak connections. Not a scenario that should happen often but weird nonetheless.