|
|
@ -89,6 +89,7 @@ public class MetaDataLoaderImpl implements MetaDataLoader { |
|
|
|
table.setName(rs.getString("TABLE_NAME")); |
|
|
|
table.setRemarks(rs.getString("REMARKS")); |
|
|
|
table.setColumns(getColumns(dataSource, catalogName, schemaName, table.getName())); |
|
|
|
table.setIndexes(getIndexs(dataSource, catalogName, schemaName, table.getName())); |
|
|
|
table.setForeignKeys(getForeignKeys(dataSource, catalogName, schemaName, table.getName())); |
|
|
|
buildSelfReference(table); |
|
|
|
result.add(table); |
|
|
@ -101,6 +102,7 @@ public class MetaDataLoaderImpl implements MetaDataLoader { |
|
|
|
table.setName(rs.getString("TABLE_NAME")); |
|
|
|
table.setRemarks(rs.getString("REMARKS")); |
|
|
|
table.setColumns(getColumns(dataSource, catalogName, schemaName, table.getName())); |
|
|
|
table.setIndexes(getIndexs(dataSource, catalogName, schemaName, table.getName())); |
|
|
|
table.setForeignKeys(getForeignKeys(dataSource, catalogName, schemaName, table.getName())); |
|
|
|
buildSelfReference(table); |
|
|
|
result.add(table); |
|
|
@ -137,6 +139,37 @@ public class MetaDataLoaderImpl implements MetaDataLoader { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private List<Index> getIndexs(DataSource dataSource, String catalogName, String schemaName, String tableName) throws MetaDataAccessException { |
|
|
|
List<Index> result =new ArrayList<>(); |
|
|
|
Connection connection =null; |
|
|
|
ResultSet rs =null; |
|
|
|
try { |
|
|
|
connection =dataSource.getConnection(); |
|
|
|
DatabaseMetaData databaseMetaData =connection.getMetaData(); |
|
|
|
rs =databaseMetaData.getIndexInfo(catalogName,schemaName,tableName,false,false); |
|
|
|
while (rs.next()){ |
|
|
|
Index index =new Index(); |
|
|
|
index.setName(rs.getString("INDEX_NAME")); |
|
|
|
index.setIndexType(IndexType.from(rs.getShort("TYPE"))); |
|
|
|
index.setUnique(!rs.getBoolean("NON_UNIQUE")); |
|
|
|
|
|
|
|
Column indexColumn =new Column(); |
|
|
|
indexColumn.setName(rs.getString("COLUMN_NAME")); |
|
|
|
List<Column> indexColumns =new ArrayList<>(); |
|
|
|
indexColumns.add(indexColumn); |
|
|
|
index.setColumns(indexColumns); |
|
|
|
|
|
|
|
result.add(index); |
|
|
|
} |
|
|
|
} catch (SQLException e) { |
|
|
|
throw new MetaDataAccessException(e); |
|
|
|
}finally { |
|
|
|
try{rs.close();} catch (SQLException e) {} |
|
|
|
try{connection.close();} catch (SQLException e) {} |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
public List<TableSummary> getTableSummary(DataSource dataSource, String catalogName, String schemaName, boolean isCount) throws MetaDataAccessException { |
|
|
|
List<Table> tables =this.getTables(dataSource,catalogName,schemaName); |
|
|
|
if(tables==null || tables.isEmpty()){ |
|
|
|