From 89a0add293077db2338393f2553a411c70f16bb0 Mon Sep 17 00:00:00 2001 From: zyyang Date: Fri, 29 Jan 2021 14:17:28 +0800 Subject: [PATCH] change --- src/connector/jdbc/pom.xml | 1 + .../jdbc/cases/TaosInfoMonitorTest.java | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TaosInfoMonitorTest.java diff --git a/src/connector/jdbc/pom.xml b/src/connector/jdbc/pom.xml index 4756ac555f..4c1ac0f06f 100755 --- a/src/connector/jdbc/pom.xml +++ b/src/connector/jdbc/pom.xml @@ -127,6 +127,7 @@ **/AppMemoryLeakTest.java + **/TaosInfoMonitorTest.java **/FailOverTest.java true diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TaosInfoMonitorTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TaosInfoMonitorTest.java new file mode 100644 index 0000000000..3c77803c55 --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/TaosInfoMonitorTest.java @@ -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 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(); + } + }); + } +} -- GitLab