The indication of whether objects will be validated before being borrowed from the pool.
If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another. testOnBorrow 不是 dbcp 定义的,是commons-pool 定义的。commons-pool 详细的定义了资源池使用的一套规范和运行流程。
/**
* Borrow an object from the pool. get object from 资源池
Returns true if the connection has not been closed and is still valid.
这个是 java.sql.Connection 定义的规范。具体实现根据对应数据库的driver 来完成。使用某种机制用来探测连接是否可用。
[code]/** * 调用 com.mysql.jdbc.MysqlIO, 发送ping 请求,检测是否可用 * 对比 H2 数据库,是通过获取当前事务级别来检测连接是否可以。但是忽略了 timeout 配置,毕竟是 demo 数据库
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!