commit
39b6ad9b22
|
@ -0,0 +1,24 @@
|
||||||
|
package com.taosdata.jdbc.cases;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class ConnectWrongDatabaseTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void connect() {
|
||||||
|
try {
|
||||||
|
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||||
|
DriverManager.getConnection("jdbc:TAOS://localhost:6030/wrong_db?user=root&password=taosdata");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
Assert.assertEquals("TDengine Error: Invalid database name", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -48,4 +48,12 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.taosdata.jdbc</groupId>
|
||||||
|
<artifactId>taos-jdbcdriver</artifactId>
|
||||||
|
<version>2.0.15</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
public class JDBCDemo {
|
public class JDBCDemo {
|
||||||
private static String host;
|
private static String host;
|
||||||
private static String driverType;
|
private static String driverType = "jni";
|
||||||
private static final String dbName = "test";
|
private static final String dbName = "test";
|
||||||
private static final String tbName = "weather";
|
private static final String tbName = "weather";
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
|
@ -21,7 +21,7 @@ public class JDBCDemo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (host == null || driverType == null) {
|
if (host == null) {
|
||||||
printHelp();
|
printHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue