我应该关闭来自数据源的连接吗? [英] Should I close a connection that came from a datasource?
本文介绍了我应该关闭来自数据源的连接吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我执行dataSource.getConnection()时,当我希望将连接返回到池中(而不是关闭)时,调用close方法是否会将连接返回到池中或实际上将其关闭?
When I do a dataSource.getConnection(), when I want the connection to be return to the pool (and not closed), does calling the close method return the connection to the pool or actually close it?
推荐答案
在数据源返回的连接上调用close()时,它将把它返回到要由其他线程使用的池中.关闭连接会破坏池的用途.
When you call the close() on connection returned by a DataSource, it would return that to the pool to be used by other thread. Closing the connection defeats the purpose of the pool.
这篇关于我应该关闭来自数据源的连接吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文