in flink-connector-jdbc/src/main/java/org/apache/flink/connector/jdbc/dialect/JdbcDialectLoader.java [49:91]
public static JdbcDialect load(String url, ClassLoader classLoader) {
List<JdbcDialectFactory> foundFactories = discoverFactories(classLoader);
if (foundFactories.isEmpty()) {
throw new IllegalStateException(
String.format(
"Could not find any jdbc dialect factories that implement '%s' in the classpath.",
JdbcDialectFactory.class.getName()));
}
final List<JdbcDialectFactory> matchingFactories =
foundFactories.stream().filter(f -> f.acceptsURL(url)).collect(Collectors.toList());
if (matchingFactories.isEmpty()) {
throw new IllegalStateException(
String.format(
"Could not find any jdbc dialect factory that can handle url '%s' that implements '%s' in the classpath.\n\n"
+ "Available factories are:\n\n"
+ "%s",
url,
JdbcDialectFactory.class.getName(),
foundFactories.stream()
.map(f -> f.getClass().getName())
.distinct()
.sorted()
.collect(Collectors.joining("\n"))));
}
if (matchingFactories.size() > 1) {
throw new IllegalStateException(
String.format(
"Multiple jdbc dialect factories can handle url '%s' that implement '%s' found in the classpath.\n\n"
+ "Ambiguous factory classes are:\n\n"
+ "%s",
url,
JdbcDialectFactory.class.getName(),
matchingFactories.stream()
.map(f -> f.getClass().getName())
.sorted()
.collect(Collectors.joining("\n"))));
}
return matchingFactories.get(0).create();
}