From 9ed2f88bbcca3f69c1c07042b1010d196d6b54e9 Mon Sep 17 00:00:00 2001 From: zyyang Date: Wed, 27 Jan 2021 13:54:39 +0800 Subject: [PATCH] change --- .../com/taosdata/demo/ConnectionPoolDemo.java | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/ConnectionPoolDemo.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/ConnectionPoolDemo.java index 2bc3059cf8..6787e07423 100644 --- a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/ConnectionPoolDemo.java +++ b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/demo/ConnectionPoolDemo.java @@ -64,31 +64,31 @@ public class ConnectionPoolDemo { logger.info(">>>>>>>>>>>>>> connection pool Type: " + poolType); init(dataSource); -// try { -// Connection connection = dataSource.getConnection(); -// Statement statement = connection.createStatement(); -// String sql = "insert into " + dbName + ".t_1 values('2020-01-01 00:00:00.000',12.12,111)"; -// int affectRows = statement.executeUpdate(sql); -// System.out.println("affectRows >>> " + affectRows); -// affectRows = statement.executeUpdate(sql); -// System.out.println("affectRows >>> " + affectRows); -// statement.close(); -// connection.close(); -// } catch (SQLException e) { -// e.printStackTrace(); -// } - - ExecutorService executor = Executors.newFixedThreadPool(threadCount); - for (long i = 0; i < totalSize / batchSize / tableSize; i++) { - executor.execute(new InsertTask(dataSource, dbName, tableSize, batchSize)); - // sleep few seconds - try { - TimeUnit.MILLISECONDS.sleep(sleep); - } catch (InterruptedException e) { - e.printStackTrace(); - } + try { + Connection connection = dataSource.getConnection(); + Statement statement = connection.createStatement(); + String sql = "insert into " + dbName + ".t_1 values('2020-01-01 00:00:00.000',12.12,111)"; + int affectRows = statement.executeUpdate(sql); + System.out.println("affectRows >>> " + affectRows); + affectRows = statement.executeUpdate(sql); + System.out.println("affectRows >>> " + affectRows); + statement.close(); + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); } - executor.shutdown(); + +// ExecutorService executor = Executors.newFixedThreadPool(threadCount); +// for (long i = 0; i < totalSize / batchSize / tableSize; i++) { +// executor.execute(new InsertTask(dataSource, dbName, tableSize, batchSize)); +// // sleep few seconds +// try { +// TimeUnit.MILLISECONDS.sleep(sleep); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } +// executor.shutdown(); } -- GitLab