English 中文(简体)
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).

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.

问题回答

暂无回答




相关问题
MaxPooledStatements setting in JDBC oracle

I can t figure out how to set MaxPooledStatements in Oracle using the Oracle thin JDBC driver. Could someone point me in the right direction?

pass ResultSet from servlet to JSP

I am doing the following in my SampleServlet.java //Fill resultset from db .... try { ArrayList Rows = new ArrayList(); while (resultSet.next()){ ArrayList row = new ArrayList(); ...

How to correctly use ResultSet with h:dataTable

The problem is, that after displaying the ResultSet with <h:dataTable>, the connection is left open. If I close it, it closes the ResultSet too. I m thinking about copying the ResultSet data ...

Mysql session variable in JDBC string

am using this connection string to connect to mysql from java: jdbc:mysql://localhost:3306/db?noDatetimeStringSync=true&useUnicode=yes&characterEncoding=UTF-8 is it possible to set the ...

热门标签