mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
数据连接建立时,执行validateConnection操作
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@207 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package com.alibaba.druid.bvt.pool;
|
||||
|
||||
public class Case3_ValidateQuery {
|
||||
|
||||
}
|
||||
@@ -42,6 +42,7 @@ public class Case1 extends TestCase {
|
||||
private String validationQuery = "SELECT 1";
|
||||
private int threadCount = 2;
|
||||
private int loopCount = 5;
|
||||
final int LOOP_COUNT = 1000 * 1000;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
jdbcUrl = "jdbc:fake:dragoon_v25masterdb";
|
||||
@@ -64,7 +65,7 @@ public class Case1 extends TestCase {
|
||||
dataSource.setUsername(user);
|
||||
dataSource.setPassword(password);
|
||||
dataSource.setValidationQuery(validationQuery);
|
||||
dataSource.setTestOnBorrow(true);
|
||||
dataSource.setTestOnBorrow(false);
|
||||
|
||||
for (int i = 0; i < loopCount; ++i) {
|
||||
p0(dataSource, "druid", threadCount);
|
||||
@@ -86,7 +87,7 @@ public class Case1 extends TestCase {
|
||||
dataSource.setUsername(user);
|
||||
dataSource.setPassword(password);
|
||||
dataSource.setValidationQuery("SELECT 1");
|
||||
dataSource.setTestOnBorrow(true);
|
||||
dataSource.setTestOnBorrow(false);
|
||||
|
||||
for (int i = 0; i < loopCount; ++i) {
|
||||
p0(dataSource, "dbcp", threadCount);
|
||||
@@ -111,7 +112,7 @@ public class Case1 extends TestCase {
|
||||
dataSource.setPartitionCount(1);
|
||||
dataSource.setAcquireIncrement(5);
|
||||
dataSource.setIdleConnectionTestPeriod(0L);
|
||||
dataSource.setDisableConnectionTracking(true);
|
||||
// dataSource.setDisableConnectionTracking(true);
|
||||
|
||||
for (int i = 0; i < loopCount; ++i) {
|
||||
p0(dataSource, "boneCP", threadCount);
|
||||
@@ -129,8 +130,8 @@ public class Case1 extends TestCase {
|
||||
public void run() {
|
||||
try {
|
||||
startLatch.await();
|
||||
final int COUNT = 1000 * 1000;
|
||||
for (int i = 0; i < COUNT; ++i) {
|
||||
|
||||
for (int i = 0; i < LOOP_COUNT; ++i) {
|
||||
Connection conn = dataSource.getConnection();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user