[TD-2776]<feature>: add stable infos in getTables method
This commit is contained in:
parent
20d0279971
commit
10b1d91070
|
@ -535,6 +535,12 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Param catalog : database名称,"" 表示不属于任何database的table,null表示不使用database来缩小范围
|
||||||
|
* @Param schemaPattern : schema名称,""表示
|
||||||
|
* @Param tableNamePattern : 表名满足tableNamePattern的表, null表示返回所有表
|
||||||
|
* @Param types : 表类型,null表示返回所有类型
|
||||||
|
*/
|
||||||
public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException {
|
public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException {
|
||||||
if (conn == null || conn.isClosed()) {
|
if (conn == null || conn.isClosed()) {
|
||||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
||||||
|
@ -544,10 +550,18 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
|
||||||
if (catalog == null || catalog.isEmpty())
|
if (catalog == null || catalog.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
stmt.executeUpdate("use " + catalog);
|
ResultSet databases = stmt.executeQuery("show databases");
|
||||||
|
while (databases.next()) {
|
||||||
|
String dbname = databases.getString("name");
|
||||||
|
}
|
||||||
|
databases.close();
|
||||||
|
|
||||||
|
stmt.execute("use " + catalog);
|
||||||
ResultSet resultSet0 = stmt.executeQuery("show tables");
|
ResultSet resultSet0 = stmt.executeQuery("show tables");
|
||||||
GetTablesResultSet getTablesResultSet = new GetTablesResultSet(resultSet0, catalog, schemaPattern, tableNamePattern, types);
|
|
||||||
return getTablesResultSet;
|
DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet();
|
||||||
|
|
||||||
|
return resultSet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -591,11 +605,8 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
|
||||||
return resultSet;
|
return resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)
|
public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
|
||||||
throws SQLException {
|
Statement stmt;
|
||||||
|
|
||||||
/** add by zyyang **********/
|
|
||||||
Statement stmt = null;
|
|
||||||
if (null != conn && !conn.isClosed()) {
|
if (null != conn && !conn.isClosed()) {
|
||||||
stmt = conn.createStatement();
|
stmt = conn.createStatement();
|
||||||
if (catalog == null || catalog.isEmpty())
|
if (catalog == null || catalog.isEmpty())
|
||||||
|
@ -691,17 +702,10 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
|
||||||
}
|
}
|
||||||
resultSet.setRowDataList(rowDataList);
|
resultSet.setRowDataList(rowDataList);
|
||||||
|
|
||||||
// GetColumnsResultSet getColumnsResultSet = new GetColumnsResultSet(resultSet0, catalog, schemaPattern, tableNamePattern, columnNamePattern);
|
|
||||||
// return getColumnsResultSet;
|
|
||||||
// DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet();
|
|
||||||
return resultSet;
|
return resultSet;
|
||||||
} else {
|
} else {
|
||||||
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************/
|
|
||||||
|
|
||||||
// return getEmptyResultSet();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getNullable(int index, String typeName) {
|
private int getNullable(int index, String typeName) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import java.util.Properties;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class StatementTest extends BaseTest {
|
public class StatementTest {
|
||||||
static Connection connection = null;
|
static Connection connection = null;
|
||||||
static Statement statement = null;
|
static Statement statement = null;
|
||||||
static String dbName = "test";
|
static String dbName = "test";
|
||||||
|
@ -26,15 +26,13 @@ public class StatementTest extends BaseTest {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host);
|
|
||||||
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/", properties);
|
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/?user=root&password=taosdata", properties);
|
||||||
|
|
||||||
statement = connection.createStatement();
|
statement = connection.createStatement();
|
||||||
statement.executeUpdate("drop database if exists " + dbName);
|
statement.executeUpdate("drop database if exists " + dbName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -54,9 +52,6 @@ public class StatementTest extends BaseTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnsupport() {
|
public void testUnsupport() {
|
||||||
// if(null == resSet) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
TSDBStatement tsdbStatement = (TSDBStatement) statement;
|
TSDBStatement tsdbStatement = (TSDBStatement) statement;
|
||||||
try {
|
try {
|
||||||
tsdbStatement.unwrap(null);
|
tsdbStatement.unwrap(null);
|
||||||
|
|
|
@ -67,9 +67,9 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.taosdata.jdbc</groupId>
|
<groupId>com.taosdata.jdbc</groupId>
|
||||||
<artifactId>taos-jdbcdriver</artifactId>
|
<artifactId>taos-jdbcdriver</artifactId>
|
||||||
<version>2.0.15</version>
|
<version>2.0.16</version>
|
||||||
<scope>system</scope>
|
<!-- <scope>system</scope>-->
|
||||||
<systemPath>${project.basedir}/src/main/resources/lib/taos-jdbcdriver-2.0.15-dist.jar</systemPath>
|
<!-- <systemPath>${project.basedir}/src/main/resources/lib/taos-jdbcdriver-2.0.15-dist.jar</systemPath>-->
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- fastjson -->
|
<!-- fastjson -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue