mirror of
https://gitee.com/dromara/hutool.git
synced 2025-06-28 13:34:09 +08:00
fix connection pool bug
This commit is contained in:
parent
b68e180ad5
commit
7c2746c76a
@ -35,6 +35,9 @@ import java.util.Properties;
|
|||||||
public class PooledConnection extends ConnectionWrapper {
|
public class PooledConnection extends ConnectionWrapper {
|
||||||
|
|
||||||
private final PooledDataSource dataSource;
|
private final PooledDataSource dataSource;
|
||||||
|
/**
|
||||||
|
* 仅用于记录连接在池中的状态,如归还到池中为close状态,从池中拿出需调用{@link #open()}变为可用状态
|
||||||
|
*/
|
||||||
private boolean isClosed = false;
|
private boolean isClosed = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,6 +102,17 @@ public class PooledConnection extends ConnectionWrapper {
|
|||||||
return this.isClosed;
|
return this.isClosed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开连接<br>
|
||||||
|
* 仅用于从连接池中拿出时调用,使链接变为可用。
|
||||||
|
*
|
||||||
|
* @return this
|
||||||
|
*/
|
||||||
|
PooledConnection open() {
|
||||||
|
this.isClosed = false;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 销毁连接,即彻底关闭并丢弃连接
|
* 销毁连接,即彻底关闭并丢弃连接
|
||||||
*/
|
*/
|
||||||
|
@ -86,7 +86,7 @@ public class PooledDataSource extends AbstractDataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PooledConnection getConnection() throws SQLException {
|
public PooledConnection getConnection() throws SQLException {
|
||||||
return connPool.borrowObject();
|
return connPool.borrowObject().open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user