提交 3f09fcb0 编写于 作者: Z zyyang

change the jdbc test cases

上级 b0f219bf
...@@ -12,7 +12,10 @@ public class TestPreparedStatement { ...@@ -12,7 +12,10 @@ public class TestPreparedStatement {
Class.forName("com.taosdata.jdbc.TSDBDriver"); Class.forName("com.taosdata.jdbc.TSDBDriver");
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, "localhost"); properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, "localhost");
connection = DriverManager.getConnection("jdbc:TAOS://localhost:0/?user=root&password=taosdata", properties); properties.setProperty(TSDBDriver.PROPERTY_KEY_USER,"root");
properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD,"taosdata");
connection = DriverManager.getConnection("jdbc:TAOS://localhost:0/", properties);
String rawSql = "select * from test.log0601"; String rawSql = "select * from test.log0601";
// String[] params = new String[]{"ts", "c1"}; // String[] params = new String[]{"ts", "c1"};
PreparedStatement pstmt = (TSDBPreparedStatement) connection.prepareStatement(rawSql); PreparedStatement pstmt = (TSDBPreparedStatement) connection.prepareStatement(rawSql);
......
...@@ -13,7 +13,10 @@ public class TestTSDBDatabaseMetaData { ...@@ -13,7 +13,10 @@ public class TestTSDBDatabaseMetaData {
Class.forName("com.taosdata.jdbc.TSDBDriver"); Class.forName("com.taosdata.jdbc.TSDBDriver");
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, "localhost"); properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, "localhost");
connection = DriverManager.getConnection("jdbc:TAOS://localhost:0/?user=root&password=taosdata", properties); properties.setProperty(TSDBDriver.PROPERTY_KEY_USER,"root");
properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD,"taosdata");
connection = DriverManager.getConnection("jdbc:TAOS://localhost:0/", properties);
dbMetaData = connection.getMetaData(); dbMetaData = connection.getMetaData();
resSet = dbMetaData.getCatalogs(); resSet = dbMetaData.getCatalogs();
while(resSet.next()) { while(resSet.next()) {
......
...@@ -16,13 +16,13 @@ public class TestTSDBSubscribe { ...@@ -16,13 +16,13 @@ public class TestTSDBSubscribe {
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_USER,"root");
properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD,"taosdata");
String cs = String.format("jdbc:TAOS://%s:0/%s?user=root&password=taosdata", host, database); String cs = String.format("jdbc:TAOS://%s:0/%s", host, database);
return (TSDBConnection)DriverManager.getConnection(cs, properties); return (TSDBConnection)DriverManager.getConnection(cs, properties);
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String usage = "java -Djava.ext.dirs=../ TestTSDBSubscribe [-host host] <-db database> <-topic topic> <-sql sql>"; String usage = "java -Djava.ext.dirs=../ TestTSDBSubscribe [-host host] <-db database> <-topic topic> <-sql sql>";
if (args.length < 2) { if (args.length < 2) {
......
...@@ -40,8 +40,10 @@ public class BatchInsertTest extends BaseTest { ...@@ -40,8 +40,10 @@ public class BatchInsertTest extends BaseTest {
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/" + "?user=root&password=taosdata" properties.setProperty(TSDBDriver.PROPERTY_KEY_USER,"root");
, properties); properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD,"taosdata");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties);
statement = connection.createStatement(); statement = connection.createStatement();
statement.executeUpdate("drop database if exists " + dbName); statement.executeUpdate("drop database if exists " + dbName);
......
...@@ -29,16 +29,17 @@ public class ConnectionTest extends BaseTest { ...@@ -29,16 +29,17 @@ public class ConnectionTest extends BaseTest {
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/" + "?user=root&password=taosdata" properties.setProperty(TSDBDriver.PROPERTY_KEY_USER,"root");
, properties); properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD,"taosdata");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties);
assertTrue(null != connection); assertTrue(null != connection);
statement = connection.createStatement(); statement = connection.createStatement();
assertTrue(null != statement); assertTrue(null != statement);
// try reconnect // try reconnect
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/" + "?user=root&password=taosdata" connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties);
, properties);
try { try {
statement.execute("create database if not exists " + dbName); statement.execute("create database if not exists " + dbName);
......
...@@ -26,8 +26,10 @@ public class DatabaseMetaDataTest extends BaseTest { ...@@ -26,8 +26,10 @@ public class DatabaseMetaDataTest extends BaseTest {
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/" + "?user=root&password=taosdata", properties.setProperty(TSDBDriver.PROPERTY_KEY_USER,"root");
properties); properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD,"taosdata");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/" , properties);
String sql = "drop database if exists " + dbName; String sql = "drop database if exists " + dbName;
statement = (TSDBPreparedStatement) connection.prepareStatement(sql); statement = (TSDBPreparedStatement) connection.prepareStatement(sql);
......
...@@ -28,8 +28,10 @@ public class ImportTest extends BaseTest { ...@@ -28,8 +28,10 @@ public class ImportTest extends BaseTest {
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/" + "?user=root&password=taosdata" properties.setProperty(TSDBDriver.PROPERTY_KEY_USER,"root");
, properties); properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD,"taosdata");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties);
statement = connection.createStatement(); statement = connection.createStatement();
statement.executeUpdate("drop database if exists " + dbName); statement.executeUpdate("drop database if exists " + dbName);
......
...@@ -33,8 +33,10 @@ public class PreparedStatementTest extends BaseTest { ...@@ -33,8 +33,10 @@ public class PreparedStatementTest extends BaseTest {
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/" + "?user=root&password=taosdata", properties.setProperty(TSDBDriver.PROPERTY_KEY_USER,"root");
properties); properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD,"taosdata");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties);
String sql = "drop database if exists " + dbName; String sql = "drop database if exists " + dbName;
statement = (TSDBPreparedStatement) connection.prepareStatement(sql); statement = (TSDBPreparedStatement) connection.prepareStatement(sql);
......
...@@ -34,9 +34,11 @@ public class ResultSetTest extends BaseTest { ...@@ -34,9 +34,11 @@ public class ResultSetTest extends BaseTest {
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_USER,"root");
properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD,"taosdata");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/" + "?user=root&password=taosdata"
, properties); connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties);
statement = connection.createStatement(); statement = connection.createStatement();
statement.executeUpdate("drop database if exists " + dbName); statement.executeUpdate("drop database if exists " + dbName);
......
...@@ -28,8 +28,10 @@ public class SelectTest extends BaseTest { ...@@ -28,8 +28,10 @@ public class SelectTest extends BaseTest {
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/" + "?user=root&password=taosdata" properties.setProperty(TSDBDriver.PROPERTY_KEY_USER,"root");
, properties); properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD,"taosdata");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/" , properties);
statement = connection.createStatement(); statement = connection.createStatement();
statement.executeUpdate("drop database if exists " + dbName); statement.executeUpdate("drop database if exists " + dbName);
......
...@@ -31,8 +31,10 @@ public class StableTest extends BaseTest { ...@@ -31,8 +31,10 @@ public class StableTest extends BaseTest {
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/" + "?user=root&password=taosdata" properties.setProperty(TSDBDriver.PROPERTY_KEY_USER,"root");
, properties); properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD,"taosdata");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/" , properties);
statement = connection.createStatement(); statement = connection.createStatement();
statement.executeUpdate("create database if not exists " + dbName); statement.executeUpdate("create database if not exists " + dbName);
......
...@@ -30,8 +30,10 @@ public class StatementTest extends BaseTest { ...@@ -30,8 +30,10 @@ public class StatementTest extends BaseTest {
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/" + "?user=root&password=taosdata" properties.setProperty(TSDBDriver.PROPERTY_KEY_USER,"root");
, properties); properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD,"taosdata");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties);
statement = connection.createStatement(); statement = connection.createStatement();
statement.executeUpdate("drop database if exists " + dbName); statement.executeUpdate("drop database if exists " + dbName);
......
...@@ -32,8 +32,10 @@ public class SubscribeTest extends BaseTest { ...@@ -32,8 +32,10 @@ public class SubscribeTest extends BaseTest {
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/" + "?user=root&password=taosdata" properties.setProperty(TSDBDriver.PROPERTY_KEY_USER,"root");
, properties); properties.setProperty(TSDBDriver.PROPERTY_KEY_PASSWORD,"taosdata");
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties);
statement = connection.createStatement(); statement = connection.createStatement();
statement.executeUpdate("create database if not exists " + dbName); statement.executeUpdate("create database if not exists " + dbName);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册