mirror of
https://github.com/WeiYe-Jing/datax-web.git
synced 2026-07-03 21:08:58 +08:00
add: 增加只获取表的所有字段名的方法;
This commit is contained in:
parent
6a6013c139
commit
2fb2d6f343
@ -250,4 +250,29 @@ public abstract class BaseQueryTool implements QueryToolInterface {
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getColumnNames(String tableName) {
|
||||
|
||||
List<String> columns = Lists.newArrayList();
|
||||
|
||||
//获取查询指定表所有字段的sql语句
|
||||
String querySql = sqlBuilder.getSQLQueryFields(tableName);
|
||||
logger.info("querySql: {}", querySql);
|
||||
|
||||
try {
|
||||
//获取所有字段
|
||||
Statement statement = connection.createStatement();
|
||||
ResultSet resultSet = statement.executeQuery(querySql);
|
||||
ResultSetMetaData metaData = resultSet.getMetaData();
|
||||
int columnCount = metaData.getColumnCount();
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
columns.add(metaData.getColumnName(i));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,10 +37,19 @@ public interface QueryToolInterface {
|
||||
public List<Map<String, Object>> getTables();
|
||||
|
||||
/**
|
||||
* 根据表名和类型映射列表获取所有字段
|
||||
* 根据表名获取所有字段
|
||||
*
|
||||
* @param tableName
|
||||
* @return2
|
||||
*/
|
||||
public List<ColumnInfo> getColumns(String tableName);
|
||||
|
||||
|
||||
/**
|
||||
* 根据表名和获取所有字段名称(不包括表名)
|
||||
*
|
||||
* @param tableName
|
||||
* @return2
|
||||
*/
|
||||
public List<String> getColumnNames(String tableName);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user