提交 c62dec73 编写于 作者: Z zyyang

change

上级 b49b361f
package com.taosdata.jdbc; package com.taosdata.jdbc;
import org.junit.After;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
...@@ -30,6 +31,8 @@ public class TSDBDriverTest { ...@@ -30,6 +31,8 @@ public class TSDBDriverTest {
private static boolean islibLoaded = false; private static boolean islibLoaded = false;
private static boolean isTaosdActived; private static boolean isTaosdActived;
private Connection conn;
@BeforeClass @BeforeClass
public static void before() { public static void before() {
String osName = System.getProperty("os.name").toLowerCase(); String osName = System.getProperty("os.name").toLowerCase();
...@@ -71,7 +74,7 @@ public class TSDBDriverTest { ...@@ -71,7 +74,7 @@ public class TSDBDriverTest {
final String url = "jdbc:TAOS://localhost:6030/log?user=root&password=taosdata"; final String url = "jdbc:TAOS://localhost:6030/log?user=root&password=taosdata";
try { try {
if (islibLoaded && isTaosdActived) { if (islibLoaded && isTaosdActived) {
Connection conn = DriverManager.getConnection(url); conn = DriverManager.getConnection(url);
assertNotNull("failure - connection should not be null", conn); assertNotNull("failure - connection should not be null", conn);
} }
} catch (SQLException e) { } catch (SQLException e) {
...@@ -89,7 +92,7 @@ public class TSDBDriverTest { ...@@ -89,7 +92,7 @@ public class TSDBDriverTest {
connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
try { try {
if (islibLoaded && isTaosdActived) { if (islibLoaded && isTaosdActived) {
Connection conn = DriverManager.getConnection(jdbcUrl, connProps); conn = DriverManager.getConnection(jdbcUrl, connProps);
assertNotNull("failure - connection should not be null", conn); assertNotNull("failure - connection should not be null", conn);
} }
} catch (SQLException e) { } catch (SQLException e) {
...@@ -107,7 +110,7 @@ public class TSDBDriverTest { ...@@ -107,7 +110,7 @@ public class TSDBDriverTest {
connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
try { try {
if (islibLoaded && isTaosdActived) { if (islibLoaded && isTaosdActived) {
Connection conn = DriverManager.getConnection(jdbcUrl, connProps); conn = DriverManager.getConnection(jdbcUrl, connProps);
assertNotNull("failure - connection should not be null", conn); assertNotNull("failure - connection should not be null", conn);
} }
} catch (SQLException e) { } catch (SQLException e) {
...@@ -205,4 +208,22 @@ public class TSDBDriverTest { ...@@ -205,4 +208,22 @@ public class TSDBDriverTest {
public void testGetParentLogger() throws SQLFeatureNotSupportedException { public void testGetParentLogger() throws SQLFeatureNotSupportedException {
assertNull("failure - getParentLogger should be be null", new TSDBDriver().getParentLogger()); assertNull("failure - getParentLogger should be be null", new TSDBDriver().getParentLogger());
} }
@After
public void after() {
Statement statement = null;
try {
statement = conn.createStatement();
ResultSet resultSet = statement.executeQuery("show databases");
ResultSetMetaData metaData = resultSet.getMetaData();
while (resultSet.next()) {
for (int i = 1; i <= metaData.getColumnCount(); i++) {
System.out.print(metaData.getColumnLabel(i) + " : " + resultSet.getString(i) + "\t");
}
System.out.println();
}
} 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.
先完成此消息的编辑!
想要评论请 注册