问题描述
我正在构建一个Web应用程序,该应用程序使用Tomcat的数据库连接池机制供内部使用.我也试图合并准备好的语句,以便应用程序更有效地检索数据.
据我了解,当连接,结果集和语句关闭时,连接会返回到池中.如果设置了适当的标志,则废弃的连接也将关闭并返回到池中.关闭连接意味着释放所有数据库游标和包括准备好的语句在内的缓存语句.那么,准备好的语句池有什么意义呢?
通用答案:)
连接对象并没有真正关闭,只有在您调用close()时才返回到池中,并且准备好的语句池基于每个连接工作,并且只要连接对象保持活动状态,它们就会被缓存.
I am building a web application that uses Tomcat's Database connection pooling mechanism for its internal use. I am trying to pool the prepared statements as well so that the application is more efficient in retrieving data.
From what I understand, connections are returned to the pool when the connection, resultset and statements are closed. If appropriate flags are set, abandoned connections are also closed and returned to the pool. Closing a connection means releasing all database cursors and cached statement including prepared statements. So whats the point of prepared statement pooling?
A generic answer :)
Connection objects are not really closed but only returned to the pool when you call close() and the prepared statement pooling works on per connection basis and they are cached as long as the connection object remains active.
这篇关于带连接池的PreparedStatement池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!