diff --git a/server/odc-service/src/main/java/com/oceanbase/odc/service/dlm/DataSourceInfoMapper.java b/server/odc-service/src/main/java/com/oceanbase/odc/service/dlm/DataSourceInfoMapper.java index fbd619c633..f817395291 100644 --- a/server/odc-service/src/main/java/com/oceanbase/odc/service/dlm/DataSourceInfoMapper.java +++ b/server/odc-service/src/main/java/com/oceanbase/odc/service/dlm/DataSourceInfoMapper.java @@ -22,6 +22,7 @@ import com.oceanbase.odc.core.shared.constant.ConnectType; import com.oceanbase.odc.core.shared.exception.UnsupportedException; import com.oceanbase.odc.plugin.connect.model.JdbcUrlProperty; +import com.oceanbase.odc.plugin.connect.model.oracle.UserRole; import com.oceanbase.odc.service.connection.model.ConnectionConfig; import com.oceanbase.odc.service.plugin.ConnectionPluginUtil; import com.oceanbase.odc.service.session.factory.OBConsoleDataSourceFactory; @@ -114,7 +115,7 @@ public static DataSourceInfo toDataSourceInfo(ConnectionConfig connectionConfig, case ORACLE: dataSourceInfo.setJdbcUrl(getJdbcUrl(connectionConfig)); dataSourceInfo.setDatabaseType(DataBaseType.ORACLE); - dataSourceInfo.setFullUserName(connectionConfig.getUsername()); + dataSourceInfo.setFullUserName(getOracleUsername(connectionConfig)); break; default: log.warn(String.format("Unsupported datasource type:%s", connectionConfig.getDialectType())); @@ -132,4 +133,9 @@ private static String getJdbcUrl(ConnectionConfig connectionConfig) { return ConnectionPluginUtil.getConnectionExtension(connectionConfig.getDialectType()) .generateJdbcUrl(jdbcUrlProperty); } + + private static String getOracleUsername(ConnectionConfig connectionConfig) { + return connectionConfig.getUserRole() == UserRole.SYSDBA ? connectionConfig.getUsername() + " as sysdba" + : connectionConfig.getUsername(); + } }