mirror of
https://gitee.com/dromara/dbswitch.git
synced 2025-10-15 06:10:23 +00:00
修正OceanBase测试连接
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
package com.gitee.dbswitch.provider.meta;
|
||||
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import com.gitee.dbswitch.common.type.ProductTypeEnum;
|
||||
import com.gitee.dbswitch.common.type.TableIndexEnum;
|
||||
import com.gitee.dbswitch.provider.AbstractCommonProvider;
|
||||
import com.gitee.dbswitch.provider.ProductFactoryProvider;
|
||||
@@ -60,6 +59,15 @@ public abstract class AbstractMetadataProvider
|
||||
this.catalogName = catalogName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testConnection(Connection connection, String pingSql) {
|
||||
try (Statement st = connection.createStatement()) {
|
||||
st.execute(pingSql);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> querySchemaList(Connection connection) {
|
||||
Set<String> ret = new LinkedHashSet<>();
|
||||
|
@@ -30,6 +30,14 @@ public interface MetadataProvider {
|
||||
*/
|
||||
ProductTypeEnum getProductType();
|
||||
|
||||
/**
|
||||
* 测试连接(原始SQL语句)
|
||||
*
|
||||
* @param connection JDBC连接
|
||||
* @param pingSql 测试连接的SQL语句
|
||||
*/
|
||||
void testConnection(Connection connection, String pingSql);
|
||||
|
||||
/**
|
||||
* 获取数据库的模式schema列表
|
||||
*
|
||||
|
@@ -103,9 +103,9 @@ public class OceanbaseMetadataQueryProvider extends AbstractMetadataProvider {
|
||||
@Override
|
||||
public void testQuerySQL(Connection connection, String sql) {
|
||||
if (StringUtils.equals(ProductTypeEnum.OCEANBASE.getSql(), sql)) {
|
||||
this.delegate.testQuerySQL(connection, this.dialect.getSql());
|
||||
this.delegate.testConnection(connection, this.dialect.getSql());
|
||||
} else {
|
||||
this.delegate.testQuerySQL(connection, sql);
|
||||
this.delegate.testConnection(connection, sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user