mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@513 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -43,6 +43,7 @@ import com.alibaba.druid.logging.Log;
|
||||
import com.alibaba.druid.logging.LogFactory;
|
||||
import com.alibaba.druid.pool.PoolablePreparedStatement.PreparedStatementKey;
|
||||
import com.alibaba.druid.pool.PreparedStatementPool.MethodType;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
|
||||
/**
|
||||
* @author wenshao<szujobs@hotmail.com>
|
||||
@@ -123,11 +124,20 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
|
||||
@Override
|
||||
public void close() throws SQLException {
|
||||
close(true);
|
||||
}
|
||||
|
||||
public void close(boolean recyle) throws SQLException {
|
||||
if (holder == null) {
|
||||
LOG.warn("dup close");
|
||||
return;
|
||||
}
|
||||
|
||||
DruidAbstractDataSource dataSource = holder.getDataSource();
|
||||
if (dataSource.isRemoveAbandoned()) {
|
||||
dataSource.getActiveConnectionStackTrace().remove(this);
|
||||
}
|
||||
|
||||
for (ConnectionEventListener listener : holder.getConnectionEventListeners()) {
|
||||
listener.connectionClosed(new ConnectionEvent(this));
|
||||
}
|
||||
@@ -142,7 +152,11 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
}
|
||||
|
||||
holder.reset();
|
||||
holder.getDataSource().recycle(this);
|
||||
if (recyle) {
|
||||
holder.getDataSource().recycle(this);
|
||||
} else {
|
||||
JdbcUtils.close(holder.getConnection());
|
||||
}
|
||||
holder = null;
|
||||
conn = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user