Merge pull request #4846 from taosdata/hotfix/TD-2286

Hotfix/td 2286
This commit is contained in:
huili 2021-01-07 15:04:53 +08:00 committed by GitHub
commit 39b6ad9b22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 2 deletions

View File

@ -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());
}
}
}

View File

@ -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>

View File

@ -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();
} }