Should I close a connection that came from a datasource?

拥有回忆 提交于 2019-12-22 04:29:13

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/4670617/should-i-close-a-connection-that-came-from-a-datasource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!