From 1e7c84f9d8a4b6c6816734deed95559e7d7e7feb Mon Sep 17 00:00:00 2001 From: zyyang Date: Tue, 24 Aug 2021 09:28:29 +0800 Subject: [PATCH] change --- .../jdbc/SetConfigurationInJNITest.java | 48 +++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SetConfigurationInJNITest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SetConfigurationInJNITest.java index c083716277..09988a4c3a 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SetConfigurationInJNITest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/SetConfigurationInJNITest.java @@ -1,8 +1,13 @@ package com.taosdata.jdbc; +import org.junit.After; +import org.junit.Before; import org.junit.Test; +import java.sql.Connection; +import java.sql.DriverManager; import java.sql.SQLException; +import java.sql.Statement; import java.util.Arrays; import static org.junit.Assert.*; @@ -13,12 +18,15 @@ public class SetConfigurationInJNITest { private String host = "127.0.0.1"; private String dbname = "test_jni"; private long maxSQLLength = 1024000; - private String debugFlagJSON = "{ \"debugFlag\": 135}"; + private String debugFlagJSON = "{ \"debugFlag\": \"135\"}"; private String maxSqlLengthJSON = "{ \"maxSQLLength\": " + maxSQLLength + "}"; @Test public void testDebugFlag() { try { + // when + TSDBJNIConnector.setConfig(debugFlagJSON); + // init TSDBJNIConnector.initImp(null); TSDBJNIConnector.setOptions(0, null); @@ -27,8 +35,6 @@ public class SetConfigurationInJNITest { String tsCharset = TSDBJNIConnector.getTsCharset(); assertEquals("", tsCharset); - TSDBJNIConnector.setConfig(debugFlagJSON); - // connect TSDBJNIConnector jniConnector = new TSDBJNIConnector(); boolean connected = jniConnector.connect(host, 0, null, "root", "taosdata"); @@ -63,4 +69,40 @@ public class SetConfigurationInJNITest { public void testMaxSQLLength() { } + + @Test + public void setConfigAfterConnect() { + try { + Connection conn = DriverManager.getConnection("jdbc:TAOS:/" + host + ":0/?user=root&password"); + + TSDBJNIConnector.setConfig(debugFlagJSON); + + Statement stmt = conn.createStatement(); + + stmt.execute("drop database if exists " + dbname); + stmt.execute("create database if not exists " + dbname); + stmt.execute("use " + dbname); + stmt.execute("create table weather(ts timestamp, f1 int) tags(loc nchar(10))"); + + stmt.close(); + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @After + public void after() { +// try { +// Connection conn = DriverManager.getConnection("jdbc:TAOS:/" + host + ":0/?user=root&password"); +// Statement stmt = conn.createStatement(); +// +//// stmt.execute("drop database if exists " + dbname); +// +// stmt.close(); +// conn.close(); +// } catch (SQLException e) { +// e.printStackTrace(); +// } + } } \ No newline at end of file -- GitLab