Browse Source

[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
3.0.0/version-upgrade
chouc 3 years ago committed by GitHub
parent
commit
900cf3a7e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/MysqlUpgradeDao.java
  2. 4
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/PostgresqlUpgradeDao.java

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

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

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

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

Loading…
Cancel
Save