连接池重用连接。 以下是apache dbcp如何工作的下划线。
Connection poolableConnection= apacheDbcpDataSource.getConnection();
阿帕奇DBCP实现返回连接包装是类型PoolableConnection的。
poolableConnection.close();
PoolableConnection.close()检查,如果实际的底层连接被关闭或没有,如果不是则返回这个PoolableConnection实例放入连接池(在这种情况下GenericObjectPool)。
if (!isUnderlyingConectionClosed) {
// Normal close: underlying connection is still open, so we
// simply need to return this proxy to the pool
try {
genericObjectPool.returnObject(this); //this is PoolableConnection instance in this case
....
}
只是好奇,但哪个连接池库启动单独的线程管理池?我不认为commons-dbcp这样做 - 至少不是BasicDataSource。相反,我认为连接检查是在连接从池中检出时完成的 – 2010-06-21 11:57:04