开发者

Having a thread using Hibernate and C3p0 with database on Tomcat

开发者 https://www.devze.com 2023-02-10 14:42 出处:网络
I am using Hibernate and C3P0 to manage my connections. I also have a thread to do database operations.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消