Skip to content

Commit 900cf3a

Browse files
authored
[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
1 parent f204447 commit 900cf3a

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/MysqlUpgradeDao.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public boolean isExistsTable(String tableName) {
6060
Connection conn = null;
6161
try {
6262
conn = dataSource.getConnection();
63-
rs = conn.getMetaData().getTables(null, null, tableName, null);
63+
rs = conn.getMetaData().getTables(conn.getCatalog(), conn.getSchema(), tableName, null);
6464
return rs.next();
6565
} catch (SQLException e) {
6666
logger.error(e.getMessage(),e);
@@ -82,7 +82,7 @@ public boolean isExistsColumn(String tableName,String columnName) {
8282
Connection conn = null;
8383
try {
8484
conn = dataSource.getConnection();
85-
ResultSet rs = conn.getMetaData().getColumns(null,null,tableName,columnName);
85+
ResultSet rs = conn.getMetaData().getColumns(conn.getCatalog(), conn.getSchema(),tableName,columnName);
8686
return rs.next();
8787

8888
} catch (SQLException e) {

dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/PostgresqlUpgradeDao.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public boolean isExistsTable(String tableName) {
8989
try {
9090
conn = dataSource.getConnection();
9191

92-
rs = conn.getMetaData().getTables(null, SCHEMA, tableName, null);
92+
rs = conn.getMetaData().getTables(conn.getCatalog(), SCHEMA, tableName, null);
9393

9494
return rs.next();
9595
} catch (SQLException e) {
@@ -113,7 +113,7 @@ public boolean isExistsColumn(String tableName,String columnName) {
113113
ResultSet rs = null;
114114
try {
115115
conn = dataSource.getConnection();
116-
rs = conn.getMetaData().getColumns(null, SCHEMA,tableName,columnName);
116+
rs = conn.getMetaData().getColumns(conn.getCatalog(), SCHEMA,tableName,columnName);
117117
return rs.next();
118118
} catch (SQLException e) {
119119
logger.error(e.getMessage(),e);

0 commit comments

Comments
 (0)