开发者

Cancel current transaction with Spring TransactionTemplate

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜