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