mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Merge branch 'master' of https://github.com/wenshao/druid
This commit is contained in:
@@ -875,7 +875,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
}
|
||||
}
|
||||
this.discardConnection(holder.getConnection());
|
||||
pooledConnection.disable();
|
||||
pooledConnection.disable(t);
|
||||
}
|
||||
|
||||
throw sqlEx;
|
||||
|
||||
@@ -53,24 +53,26 @@ import com.alibaba.druid.support.logging.LogFactory;
|
||||
*/
|
||||
public class DruidPooledConnection extends PoolableWrapper implements javax.sql.PooledConnection, Connection {
|
||||
|
||||
private final static Log LOG = LogFactory.getLog(DruidPooledConnection.class);
|
||||
private final static Log LOG = LogFactory.getLog(DruidPooledConnection.class);
|
||||
|
||||
protected Connection conn;
|
||||
protected volatile DruidConnectionHolder holder;
|
||||
protected TransactionInfo transactionInfo;
|
||||
private final boolean dupCloseLogEnable;
|
||||
private volatile boolean traceEnable = false;
|
||||
private boolean disable = false;
|
||||
private boolean closed = false;
|
||||
private volatile boolean traceEnable = false;
|
||||
private boolean disable = false;
|
||||
private boolean closed = false;
|
||||
private final Thread ownerThread;
|
||||
|
||||
private long connectedTimeNano;
|
||||
private volatile boolean running = false;
|
||||
private volatile boolean running = false;
|
||||
|
||||
private volatile boolean abandoned = false;
|
||||
private volatile boolean abandoned = false;
|
||||
|
||||
private StackTraceElement[] connectStackTrace;
|
||||
|
||||
private Throwable disableError = null;
|
||||
|
||||
public DruidPooledConnection(DruidConnectionHolder holder){
|
||||
super(holder.getConnection());
|
||||
|
||||
@@ -148,7 +150,7 @@ public class DruidPooledConnection extends PoolableWrapper implements javax.sql.
|
||||
if (rawStatement.getConnection().isClosed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
LOG.error("clear parameter error", ex);
|
||||
}
|
||||
}
|
||||
@@ -179,10 +181,15 @@ public class DruidPooledConnection extends PoolableWrapper implements javax.sql.
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
disable(null);
|
||||
}
|
||||
|
||||
public void disable(Throwable error) {
|
||||
this.traceEnable = false;
|
||||
this.holder = null;
|
||||
this.transactionInfo = null;
|
||||
this.disable = true;
|
||||
this.disableError = error;
|
||||
}
|
||||
|
||||
public boolean isDisable() {
|
||||
@@ -1012,8 +1019,16 @@ public class DruidPooledConnection extends PoolableWrapper implements javax.sql.
|
||||
}
|
||||
|
||||
public void checkState() throws SQLException {
|
||||
if (holder == null || closed || disable) {
|
||||
throw new SQLException("connection is closed");
|
||||
if (holder == null) {
|
||||
throw new SQLException("connection holder is null");
|
||||
}
|
||||
|
||||
if (closed) {
|
||||
throw new SQLException("connection closed");
|
||||
}
|
||||
|
||||
if (disable) {
|
||||
throw new SQLException("connection disabled", disableError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user