开发者

Cancel current transaction with Spring TransactionTemplate

开发者 https://www.devze.com 2023-04-01 19:05 出处:网络
I am using a connection pool and the Spring TransactionTemplate. If you want to shutdown the connection pool first all connection have to be returned to the pool, this means connection.close() has to

I am using a connection pool and the Spring TransactionTemplate. If you want to shutdown the connection pool first all connection have to be returned to the pool, this means connection.close() has to be called. I have one thread using the TransactionTemplate for some queries and another thread that wants to call some shutdown method on the connection pool, but before doing this it first has to tell the TransactionTemplate to close all connection (actually only returning them to the pool开发者_C百科).

How can this be done in Spring to immediately call close on the used connection?


If you are using Hibernate along with Spring please use:

hibernate.connection.release_mode=after_transaction

If you want to release connection just after transaction.

hibernate.connection.release_mode=after_statement

If you want to release connection after each statement

This two settings are the only ways I know that will make used connection being released faster than the default behavior. At least as far as Hibernate is concerned. If you are using other library please describe which.

0

精彩评论

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