提交 1e7c84f9 编写于 作者: Z zyyang

change

上级 2bd441bb
package com.taosdata.jdbc; package com.taosdata.jdbc;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement;
import java.util.Arrays; import java.util.Arrays;
import static org.junit.Assert.*; import static org.junit.Assert.*;
...@@ -13,12 +18,15 @@ public class SetConfigurationInJNITest { ...@@ -13,12 +18,15 @@ public class SetConfigurationInJNITest {
private String host = "127.0.0.1"; private String host = "127.0.0.1";
private String dbname = "test_jni"; private String dbname = "test_jni";
private long maxSQLLength = 1024000; private long maxSQLLength = 1024000;
private String debugFlagJSON = "{ \"debugFlag\": 135}"; private String debugFlagJSON = "{ \"debugFlag\": \"135\"}";
private String maxSqlLengthJSON = "{ \"maxSQLLength\": " + maxSQLLength + "}"; private String maxSqlLengthJSON = "{ \"maxSQLLength\": " + maxSQLLength + "}";
@Test @Test
public void testDebugFlag() { public void testDebugFlag() {
try { try {
// when
TSDBJNIConnector.setConfig(debugFlagJSON);
// init // init
TSDBJNIConnector.initImp(null); TSDBJNIConnector.initImp(null);
TSDBJNIConnector.setOptions(0, null); TSDBJNIConnector.setOptions(0, null);
...@@ -27,8 +35,6 @@ public class SetConfigurationInJNITest { ...@@ -27,8 +35,6 @@ public class SetConfigurationInJNITest {
String tsCharset = TSDBJNIConnector.getTsCharset(); String tsCharset = TSDBJNIConnector.getTsCharset();
assertEquals("", tsCharset); assertEquals("", tsCharset);
TSDBJNIConnector.setConfig(debugFlagJSON);
// connect // connect
TSDBJNIConnector jniConnector = new TSDBJNIConnector(); TSDBJNIConnector jniConnector = new TSDBJNIConnector();
boolean connected = jniConnector.connect(host, 0, null, "root", "taosdata"); boolean connected = jniConnector.connect(host, 0, null, "root", "taosdata");
...@@ -63,4 +69,40 @@ public class SetConfigurationInJNITest { ...@@ -63,4 +69,40 @@ public class SetConfigurationInJNITest {
public void testMaxSQLLength() { 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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册