diff --git a/src/modules/app.provider.ts b/src/modules/app.provider.ts index 78a5cbd..c1b83e2 100644 --- a/src/modules/app.provider.ts +++ b/src/modules/app.provider.ts @@ -6,7 +6,7 @@ BI.provider('dec.connection.provider.datebase', function () { function starRocksResolve(url: string) { // 处理starRocks数据连接常规模式 - const result = url.match(/^jdbc:mysql:\/\/([0-9a-zA-Z_\\.-]+):([0-9a-zA-Z_\\.-]+)\/([0-9a-zA-Z_\\.-]+)\.([^]+)(.*)/i); + let result = url.match(/^jdbc:mysql:\/\/([0-9a-zA-Z_\\.-]+):([0-9a-zA-Z_\\.-]+)\/([0-9a-zA-Z_\\.-]+)\.([^]+)(.*)/i); if (result) { return { host: result[1], @@ -15,10 +15,22 @@ BI.provider('dec.connection.provider.datebase', function () { databaseName: result[4], urlInfo: result[0], }; + } else { + // 兼容老数据库里面没有catalog的情况 + result = url.match(/^jdbc:mysql:\/\/([0-9a-zA-Z_\\.-]+):([0-9a-zA-Z_\\.-]+)\/([^]+)(.*)/i); + if (result) { + return { + host: result[1], + port: result[2] === 'port' ? '' : result[2], + catalog: '', + databaseName: result[3], + urlInfo: result[0], + }; + } } // 处理starRocks数据连接负载均衡模式 - const loadBalance = url.match(/^jdbc:mysql:loadbalance:\/\/[^/]+\/([^/]+)\.([^/]+)/i); - if (loadBalance){ + let loadBalance = url.match(/^jdbc:mysql:loadbalance:\/\/[^/]+\/([^/]+)\.([^/]+)/i); + if (loadBalance) { return { host: '', port: '', @@ -26,6 +38,18 @@ BI.provider('dec.connection.provider.datebase', function () { databaseName: loadBalance[2], urlInfo: loadBalance[0], } + } else { + // 兼容老数据库里面没有catalog的情况 + loadBalance = url.match(/^jdbc:mysql:loadbalance:\/\/[^/]+\/([^/]+)([^/]+)/i); + if (loadBalance) { + return { + host: '', + port: '', + catalog: '', + databaseName: loadBalance[1], + urlInfo: loadBalance[0], + } + } } return { host: '',