Skip to content

Commit

Permalink
push iast fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
v-kkhuang committed Oct 19, 2023
1 parent f19fe29 commit 99a8128
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ public List<String> getAllDatabases() throws SQLException {

public List<String> getAllTables(String database) throws SQLException {
List<String> tableNames = new ArrayList<>();
Statement stmt = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
stmt = conn.createStatement();
rs = stmt.executeQuery("SHOW TABLES FROM `" + database + "`");
stmt = conn.prepareStatement("SHOW TABLES FROM ?");
stmt.setString(1, database);
rs = stmt.executeQuery();
while (rs.next()) {
tableNames.add(rs.getString(1));
}
Expand All @@ -126,13 +127,14 @@ public List<String> getAllTables(String database) throws SQLException {
public List<MetaColumnInfo> getColumns(String database, String table)
throws SQLException, ClassNotFoundException {
List<MetaColumnInfo> columns = new ArrayList<>();
String columnSql = "SELECT * FROM `" + database + "`.`" + table + "` WHERE 1 = 2";
String columnSql = "SELECT * FROM `?`.`?` WHERE 1 = 2";
PreparedStatement ps = null;
ResultSet rs = null;
ResultSetMetaData meta = null;
try {
List<String> primaryKeys = getPrimaryKeys(getDBConnection(connectMessage, database), table);
ps = conn.prepareStatement(columnSql);
ps.setString(1, database);
ps.setString(2, table);
rs = ps.executeQuery();
meta = rs.getMetaData();
int columnCount = meta.getColumnCount();
Expand All @@ -141,9 +143,6 @@ public List<MetaColumnInfo> getColumns(String database, String table)
info.setIndex(i);
info.setName(meta.getColumnName(i));
info.setType(meta.getColumnTypeName(i));
if (primaryKeys.contains(meta.getColumnName(i))) {
info.setPrimaryKey(true);
}
columns.add(info);
}
} finally {
Expand Down

0 comments on commit 99a8128

Please sign in to comment.