mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for duplicate getUpdateCount
This commit is contained in:
@@ -43,34 +43,53 @@ import com.alibaba.druid.support.logging.LogFactory;
|
||||
|
||||
public class MockDriver implements Driver, MockDriverMBean {
|
||||
|
||||
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;
|
||||
private boolean logExecuteQueryEnable = true;
|
||||
|
||||
private final static String MBEAN_NAME = "com.alibaba.druid:type=MockDriver";
|
||||
private final static String MBEAN_NAME = "com.alibaba.druid:type=MockDriver";
|
||||
|
||||
private MockConnectionFactory connectionFactory = new MockConnectionFactoryImpl();
|
||||
private MockPreparedStatementFactory preparedStatementFactory = new MockPreparedStatementFactoryImpl();
|
||||
|
||||
static {
|
||||
registerDriver(instance);
|
||||
}
|
||||
|
||||
public MockConnectionFactory getConnectionFactory() {
|
||||
return connectionFactory;
|
||||
}
|
||||
|
||||
public void setConnectionFactory(MockConnectionFactory connectionFactory) {
|
||||
this.connectionFactory = connectionFactory;
|
||||
}
|
||||
|
||||
public MockPreparedStatementFactory getPreparedStatementFactory() {
|
||||
return preparedStatementFactory;
|
||||
}
|
||||
|
||||
public void setPreparedStatementFactory(MockPreparedStatementFactory preparedStatementFactory) {
|
||||
this.preparedStatementFactory = preparedStatementFactory;
|
||||
}
|
||||
|
||||
public boolean isLogExecuteQueryEnable() {
|
||||
return logExecuteQueryEnable;
|
||||
}
|
||||
@@ -97,11 +116,11 @@ public class MockDriver implements Driver, MockDriverMBean {
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getConnectionsSize() {
|
||||
return this.connections.size();
|
||||
}
|
||||
|
||||
|
||||
public List<MockConnection> getConnections() {
|
||||
return connections;
|
||||
}
|
||||
@@ -154,7 +173,7 @@ public class MockDriver implements Driver, MockDriverMBean {
|
||||
public void setExecuteHandler(MockExecuteHandler executeHandler) {
|
||||
this.executeHandler = executeHandler;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Connection connect(String url, Properties info) throws SQLException {
|
||||
if (!acceptsURL(url)) {
|
||||
@@ -173,7 +192,7 @@ public class MockDriver implements Driver, MockDriverMBean {
|
||||
}
|
||||
}
|
||||
|
||||
MockConnection conn = new MockConnection(this, url, info);
|
||||
MockConnection conn = connectionFactory.createConnection(this, url, info);
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("connect, url " + url + ", id " + conn.getId());
|
||||
|
||||
Reference in New Issue
Block a user