org.anyline.data.jdbc.adapter.init.CommonJDBCAdapter Maven / Gradle / Ivy
/*
* Copyright 2006-2023 www.anyline.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.anyline.data.jdbc.adapter.init;
import org.anyline.data.adapter.CommonAdapter;
import org.anyline.data.runtime.DataRuntime;
import org.anyline.util.ConfigTable;
public class CommonJDBCAdapter extends AbstractJDBCAdapter implements CommonAdapter {
/**
* 验证运行环境与当前适配器是否匹配
* 默认不连接只根据连接参数
* 只有同一个种区分不同版本(如mmsql2000/mssql2005)或不同模式(如kingbase的oracle/pg模式)时才需要单独实现
* @param runtime 运行环境主要包含驱动适配器 数据源或客户端
* @param compensate 是否补偿匹配,第一次失败后,会再匹配一次,第二次传入true
* @return boolean
*/
@Override
public boolean match(DataRuntime runtime, String feature, String adapterKey, boolean compensate) {
if(!ConfigTable.IS_ENABLE_COMMON_JDBC_ADAPTER) {
return false;
}
//第二次匹配时再执行
if(compensate && null != feature && feature.contains(":jdbc:")) {
return true;
}
return false;
}
}