[Fix][DAS] Specify the catalog and schema when check table or column exists (#6646)

* Specify the catalog and schema when check table and column exsits
refactor-ui
chouc 2021-11-02 13:33:25 +08:00 committed by GitHub
parent f20444792c
commit 900cf3a7e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -60,7 +60,7 @@ public class MysqlUpgradeDao extends UpgradeDao {
Connection conn = null;
try {
conn = dataSource.getConnection();
rs = conn.getMetaData().getTables(null, null, tableName, null);
rs = conn.getMetaData().getTables(conn.getCatalog(), conn.getSchema(), tableName, null);
return rs.next();
} catch (SQLException e) {
logger.error(e.getMessage(),e);
@ -82,7 +82,7 @@ public class MysqlUpgradeDao extends UpgradeDao {
Connection conn = null;
try {
conn = dataSource.getConnection();
ResultSet rs = conn.getMetaData().getColumns(null,null,tableName,columnName);
ResultSet rs = conn.getMetaData().getColumns(conn.getCatalog(), conn.getSchema(),tableName,columnName);
return rs.next();
} catch (SQLException e) {

View File

@ -89,7 +89,7 @@ public class PostgresqlUpgradeDao extends UpgradeDao {
try {
conn = dataSource.getConnection();
rs = conn.getMetaData().getTables(null, SCHEMA, tableName, null);
rs = conn.getMetaData().getTables(conn.getCatalog(), SCHEMA, tableName, null);
return rs.next();
} catch (SQLException e) {
@ -113,7 +113,7 @@ public class PostgresqlUpgradeDao extends UpgradeDao {
ResultSet rs = null;
try {
conn = dataSource.getConnection();
rs = conn.getMetaData().getColumns(null, SCHEMA,tableName,columnName);
rs = conn.getMetaData().getColumns(conn.getCatalog(), SCHEMA,tableName,columnName);
return rs.next();
} catch (SQLException e) {
logger.error(e.getMessage(),e);