use of io.mycat.route.parser.druid.impl.DruidSelectDb2Parser in project Mycat-Server by MyCATApache.
the class DruidParserFactory method getDruidParserForMultiDB.
private static DruidParser getDruidParserForMultiDB(SchemaConfig schema, SQLStatement statement, SchemaStatVisitor visitor) {
DruidParser parser = null;
//先解出表,判断表所在db的类型,再根据不同db类型返回不同的解析
List<String> tables = parseTables(statement, visitor);
for (String table : tables) {
Set<String> dbTypes = null;
TableConfig tableConfig = schema.getTables().get(table);
if (tableConfig == null) {
dbTypes = new HashSet<>();
dbTypes.add(schema.getDefaultDataNodeDbType());
} else {
dbTypes = tableConfig.getDbTypes();
}
if (dbTypes.contains("oracle")) {
parser = new DruidSelectOracleParser();
break;
} else if (dbTypes.contains("db2")) {
parser = new DruidSelectDb2Parser();
break;
} else if (dbTypes.contains("sqlserver")) {
parser = new DruidSelectSqlServerParser();
break;
} else if (dbTypes.contains("postgresql")) {
parser = new DruidSelectPostgresqlParser();
break;
}
}
return parser;
}
Aggregations