This commit is contained in:
zyyang 2021-01-29 14:17:28 +08:00
parent 7270014176
commit 89a0add293
2 changed files with 38 additions and 0 deletions

View File

@ -127,6 +127,7 @@
</includes>
<excludes>
<exclude>**/AppMemoryLeakTest.java</exclude>
<exclude>**/TaosInfoMonitorTest.java</exclude>
<exclude>**/FailOverTest.java</exclude>
</excludes>
<testFailureIgnore>true</testFailureIgnore>

View File

@ -0,0 +1,37 @@
package com.taosdata.jdbc.cases;
import org.junit.Test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class TaosInfoMonitorTest {
@Test
public void testCreateTooManyConnection() throws ClassNotFoundException, SQLException, InterruptedException {
Class.forName("com.taosdata.jdbc.TSDBDriver");
int conCnt = 0;
final String url = "jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata";
List<Connection> connectionList = IntStream.range(0, 100).mapToObj(i -> {
try {
return DriverManager.getConnection(url);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}).collect(Collectors.toList());
connectionList.stream().forEach(conn -> {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
});
}
}