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@620 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -37,30 +37,40 @@ import com.alibaba.druid.mock.handler.MySqlMockExecuteHandlerImpl;
|
||||
|
||||
public class MockDriver implements Driver {
|
||||
|
||||
private final static Log LOG = LogFactory.getLog(MockDriver.class);
|
||||
private final static Log LOG = LogFactory.getLog(MockDriver.class);
|
||||
|
||||
public final static MockExecuteHandler DEFAULT_HANDLER = new MySqlMockExecuteHandlerImpl();
|
||||
public final static MockExecuteHandler DEFAULT_HANDLER = new MySqlMockExecuteHandlerImpl();
|
||||
|
||||
private String prefix = "jdbc:fake:";
|
||||
private String mockPrefix = "jdbc:mock:";
|
||||
private String prefix = "jdbc:fake:";
|
||||
private String mockPrefix = "jdbc:mock:";
|
||||
|
||||
private MockExecuteHandler executeHandler = DEFAULT_HANDLER;
|
||||
private MockExecuteHandler executeHandler = DEFAULT_HANDLER;
|
||||
|
||||
public final static MockDriver instance = new MockDriver();
|
||||
public final static MockDriver instance = new MockDriver();
|
||||
|
||||
private final AtomicLong connectCount = new AtomicLong();
|
||||
private final AtomicLong connectionCloseCount = new AtomicLong();
|
||||
private final AtomicLong connectCount = new AtomicLong();
|
||||
private final AtomicLong connectionCloseCount = new AtomicLong();
|
||||
|
||||
private final AtomicLong connectionIdSeed = new AtomicLong(1000L);
|
||||
private final AtomicLong connectionIdSeed = new AtomicLong(1000L);
|
||||
|
||||
private final List<MockConnection> connections = new CopyOnWriteArrayList<MockConnection>();
|
||||
private final List<MockConnection> connections = new CopyOnWriteArrayList<MockConnection>();
|
||||
|
||||
private long idleTimeCount = 1000 * 60 * 3;
|
||||
private long idleTimeCount = 1000 * 60 * 3;
|
||||
|
||||
private boolean logExecuteQueryEnable = true;
|
||||
|
||||
static {
|
||||
registerDriver(instance);
|
||||
}
|
||||
|
||||
public boolean isLogExecuteQueryEnable() {
|
||||
return logExecuteQueryEnable;
|
||||
}
|
||||
|
||||
public void setLogExecuteQueryEnable(boolean logExecuteQueryEnable) {
|
||||
this.logExecuteQueryEnable = logExecuteQueryEnable;
|
||||
}
|
||||
|
||||
public long getIdleTimeCount() {
|
||||
return idleTimeCount;
|
||||
}
|
||||
@@ -134,7 +144,7 @@ public class MockDriver implements Driver {
|
||||
}
|
||||
|
||||
MockConnection conn = new MockConnection(this, info);
|
||||
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("connect, url " + url + ", id " + conn.getId());
|
||||
}
|
||||
@@ -196,7 +206,7 @@ public class MockDriver implements Driver {
|
||||
}
|
||||
|
||||
protected ResultSet executeQuery(MockStatement stmt, String sql) throws SQLException {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
if (logExecuteQueryEnable && LOG.isDebugEnabled()) {
|
||||
LOG.debug("executeQuery " + sql);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user