git-svn-id: http://code.alibabatech.com/svn/druid/trunk@513 b9813039-fb51-4c41-a8b9-e21c2acb5095

This commit is contained in:
wenshao
2011-07-25 13:10:57 +00:00
parent c457201d71
commit 26666ed37b
2 changed files with 21 additions and 14 deletions
@@ -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;
}