improve error info

This commit is contained in:
wenshao
2013-02-28 23:28:32 +08:00
parent 907063f33e
commit 676b1a0ef3
2 changed files with 18 additions and 11 deletions
@@ -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() {
@@ -1015,13 +1022,13 @@ public class DruidPooledConnection extends PoolableWrapper implements javax.sql.
if (holder == null) {
throw new SQLException("connection holder is null");
}
if (closed) {
throw new SQLException("connection closed");
}
if (disable) {
throw new SQLException("connection disabled");
throw new SQLException("connection disabled", disableError);
}
}