当数据库为hive时,查看schema时将url设置成空

This commit is contained in:
tmlx1990
2024-03-13 01:22:20 +08:00
parent 2292f3dad7
commit 5c40fc6beb

View File

@ -80,9 +80,13 @@ public class DatabaseServiceImpl implements DatabaseService {
if (CollectionUtils.isEmpty(schemas)) { if (CollectionUtils.isEmpty(schemas)) {
return; return;
} }
String ulr = null; String url = null;
try { try {
ulr = connection.getMetaData().getURL(); if (connection.getMetaData().getClass().getName().contains("HiveDatabaseMetaData")) {
url = "";
} else {
url = connection.getMetaData().getURL();
}
} catch (SQLException e) { } catch (SQLException e) {
log.error("get url error", e); log.error("get url error", e);
} }
@ -90,7 +94,7 @@ public class DatabaseServiceImpl implements DatabaseService {
int num = -1; int num = -1;
for (int i = 0; i < schemas.size(); i++) { for (int i = 0; i < schemas.size(); i++) {
String schema = schemas.get(i).getName(); String schema = schemas.get(i).getName();
if (StringUtils.isNotBlank(ulr) && schema!=null && ulr.contains(schema)) { if (StringUtils.isNotBlank(url) && schema!=null && url.contains(schema)) {
num = i; num = i;
break; break;
} }