数据库连接池和connection.close() [英] Database connection pooling and connection.close()

查看:401
本文介绍了数据库连接池和connection.close()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在从数据库池(例如Commons DBCP等)获得连接的情况下,并且使用connection.close()关闭连接时,如何将连接返回到池中?

In the scenario where a connection is got from a database pool(like Commons DBCP, etc) and when the connection is closed using connection.close(), how is the connection returned to the pool?

连接对象中是否存在回调方法,该方法在connection.close()上调用,该方法将连接返回到其起源的池中?

Is there come callback method in connection object which is called on connection.close() which returns the connection back to the pool from which it originated?

推荐答案

通常,您收到的连接对象是原始对象的装饰器,并调用 close 只是将其返回到池中。它不会关闭它。

Usually the connection object you receive is a decorator of the original one and calling close simply returns it to the pool. It does not close it.

这篇关于数据库连接池和connection.close()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆