I am using Hibernate and C3P0 to manage my connections. I also have a thread to do database operations.
The problem is when I undeploy my webapp from tomcat, my thread exits correctly, but the connection pool stil开发者_如何学运维l remains, there are still connections in mysql, I think they are managed by C3P0.
Is there a way to force C3P0 to shutdown all these connections?
Thanks
Check PooledDataSource object, it has a method called hardReset
. It's spec says
Destroys all pooled and checked-out Connections associated with this DataSource immediately. The PooledDataSource is reset to its initial state prior to first Connection acquisition, with no pools yet active, but ready for requests.
I would assume this should do what you are asking for.
精彩评论