druid 连接瘦身-主动回收连接

// 回收长期未归还的连接(再次说明:该方法仅在 removeAbandoned 设置为 true 的情况下触发) public int removeAbandoned() { int removeCount = 0; long currrentNanos = System.nan

Druid 

druid 丢弃连接的守护线程

// 连接池瘦身,参考主流程4 public class DestroyConnectionThread extends Thread { public DestroyConnectionThread(String name) { // 给线程重命名 sup

Druid 

druid 连接可用性测试

// 数据库连接可用性测试 protected boolean testConnectionInternal(DruidConnectionHolder holder, Connection conn) { String sqlFile = JdbcSqlStat.getContextSql

Druid 

druid 获取连接实现

private DruidPooledConnection getConnectionInternal(long maxWait) throws SQLException { // 可用性判断 if (closed) { connectErrorCountUpdate

Druid 

druid 责任链

// DruidDataSource 类里的方法:获取连接 public DruidPooledConnection getConnection(long maxWaitMillis) throws SQLException { init(); // 责任链上的 filter 存在

Druid 

druid 连接池瘦身

// 连接池瘦身 public void shrink(boolean checkTime, boolean keepAlive) { try { lock.lockInterruptibly(); } catch (InterruptedException e) {

Druid 

druid 获取连接源码

public DruidPooledConnection getConnection(long maxWaitMillis) throws SQLException { // 初始化,即主流程2 init(); if (filters.size() > 0) {

Druid 

druid 新增连接

// DruidDataSource 的内部类,对应主流程3,用来补充连接 public class CreateConnectionThread extends Thread { public CreateConnectionThread(String name){ //

Druid 

druid 初始化连接池

public void init() throws SQLException { if (inited) { // 如果已经被初始化过,则终止该方法 return; } // bug fixed for dead lock, for issu

Druid 

druid 丢弃连接

// 丢弃连接 public void discardConnection(DruidConnectionHolder holder) { if (holder == null) { return; } Connection conn = holder.ge

Druid