change
This commit is contained in:
parent
4292121dea
commit
bc2275d814
|
@ -551,16 +551,91 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
ResultSet databases = stmt.executeQuery("show databases");
|
ResultSet databases = stmt.executeQuery("show databases");
|
||||||
|
String dbname = null;
|
||||||
while (databases.next()) {
|
while (databases.next()) {
|
||||||
String dbname = databases.getString("name");
|
dbname = databases.getString("name");
|
||||||
|
if (dbname.equalsIgnoreCase(catalog))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
databases.close();
|
databases.close();
|
||||||
|
if (dbname == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
stmt.execute("use " + catalog);
|
stmt.execute("use " + dbname);
|
||||||
ResultSet resultSet0 = stmt.executeQuery("show tables");
|
|
||||||
|
|
||||||
DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet();
|
DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet();
|
||||||
|
List<ColumnMetaData> columnMetaDataList = new ArrayList<>();
|
||||||
|
ColumnMetaData col1 = new ColumnMetaData();
|
||||||
|
col1.setColIndex(1);
|
||||||
|
col1.setColName("TABLE_CAT");
|
||||||
|
col1.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||||
|
columnMetaDataList.add(col1);
|
||||||
|
ColumnMetaData col2 = new ColumnMetaData();
|
||||||
|
col2.setColIndex(2);
|
||||||
|
col2.setColName("TABLE_SCHEM");
|
||||||
|
col2.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||||
|
columnMetaDataList.add(col2);
|
||||||
|
ColumnMetaData col3 = new ColumnMetaData();
|
||||||
|
col3.setColIndex(3);
|
||||||
|
col3.setColName("TABLE_NAME");
|
||||||
|
col3.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||||
|
columnMetaDataList.add(col3);
|
||||||
|
ColumnMetaData col4 = new ColumnMetaData();
|
||||||
|
col4.setColIndex(4);
|
||||||
|
col4.setColName("TABLE_TYPE");
|
||||||
|
col4.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||||
|
columnMetaDataList.add(col4);
|
||||||
|
ColumnMetaData col5 = new ColumnMetaData();
|
||||||
|
col5.setColIndex(5);
|
||||||
|
col5.setColName("REMARKS");
|
||||||
|
col5.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||||
|
columnMetaDataList.add(col5);
|
||||||
|
ColumnMetaData col6 = new ColumnMetaData();
|
||||||
|
col6.setColIndex(6);
|
||||||
|
col6.setColName("TYPE_CAT");
|
||||||
|
col6.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||||
|
columnMetaDataList.add(col6);
|
||||||
|
ColumnMetaData col7 = new ColumnMetaData();
|
||||||
|
col7.setColIndex(7);
|
||||||
|
col7.setColName("TYPE_SCHEM");
|
||||||
|
col7.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||||
|
columnMetaDataList.add(col7);
|
||||||
|
ColumnMetaData col8 = new ColumnMetaData();
|
||||||
|
col8.setColIndex(8);
|
||||||
|
col8.setColName("TYPE_NAME");
|
||||||
|
col8.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||||
|
columnMetaDataList.add(col8);
|
||||||
|
ColumnMetaData col9 = new ColumnMetaData();
|
||||||
|
col9.setColIndex(9);
|
||||||
|
col9.setColName("SELF_REFERENCING_COL_NAME");
|
||||||
|
col9.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||||
|
columnMetaDataList.add(col9);
|
||||||
|
ColumnMetaData col10 = new ColumnMetaData();
|
||||||
|
col10.setColIndex(10);
|
||||||
|
col10.setColName("REF_GENERATION");
|
||||||
|
col10.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||||
|
columnMetaDataList.add(col10);
|
||||||
|
resultSet.setColumnMetaDataList(columnMetaDataList);
|
||||||
|
|
||||||
|
|
||||||
|
List<TSDBResultSetRowData> rowDataList = new ArrayList<>();
|
||||||
|
ResultSet tables = stmt.executeQuery("show tables");
|
||||||
|
while (tables.next()) {
|
||||||
|
TSDBResultSetRowData rowData = new TSDBResultSetRowData(10);
|
||||||
|
rowData.setString(3, tables.getString("name"));
|
||||||
|
rowData.setString(4, "TABLE");
|
||||||
|
rowData.setString(5, "");
|
||||||
|
rowDataList.add(rowData);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultSet stables = stmt.executeQuery("show stables");
|
||||||
|
while (stables.next()) {
|
||||||
|
TSDBResultSetRowData rowData = new TSDBResultSetRowData(10);
|
||||||
|
rowData.setString(3, tables.getString("name"));
|
||||||
|
rowData.setString(4, "TABLE");
|
||||||
|
rowData.setString(5, "STABLE");
|
||||||
|
rowDataList.add(rowData);
|
||||||
|
}
|
||||||
|
resultSet.setRowDataList(rowDataList);
|
||||||
return resultSet;
|
return resultSet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -606,6 +681,7 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
|
public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
|
||||||
|
// add by zyyang-taosdata
|
||||||
Statement stmt;
|
Statement stmt;
|
||||||
if (null != conn && !conn.isClosed()) {
|
if (null != conn && !conn.isClosed()) {
|
||||||
stmt = conn.createStatement();
|
stmt = conn.createStatement();
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class TSDBResultSetRowData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TSDBResultSetRowData() {
|
public TSDBResultSetRowData() {
|
||||||
this.data = new ArrayList<Object>();
|
this.data = new ArrayList<>();
|
||||||
this.setColSize(0);
|
this.setColSize(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class TSDBResultSetRowData {
|
||||||
if (this.colSize == 0) {
|
if (this.colSize == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.data = new ArrayList<Object>(colSize);
|
this.data = new ArrayList<>(colSize);
|
||||||
this.data.addAll(Collections.nCopies(this.colSize, null));
|
this.data.addAll(Collections.nCopies(this.colSize, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue