Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public abstract class JdbcClient {
private static final int HTTP_TIMEOUT_MS = 10000;
protected static final int JDBC_DATETIME_SCALE = 6;

private static final Map<URL, ClassLoader> classLoaderMap = new ConcurrentHashMap<>();

private String catalog;
protected String dbType;
protected String jdbcUser;
Expand Down Expand Up @@ -145,11 +147,16 @@ private void initializeDataSource(JdbcClientConfig config) {
}
}

private void initializeClassLoader(JdbcClientConfig config) {
private synchronized void initializeClassLoader(JdbcClientConfig config) {
try {
URL[] urls = {new URL(JdbcResource.getFullDriverUrl(config.getDriverUrl()))};
ClassLoader parent = getClass().getClassLoader();
this.classLoader = URLClassLoader.newInstance(urls, parent);
if (classLoaderMap.containsKey(urls[0])) {
this.classLoader = classLoaderMap.get(urls[0]);
} else {
ClassLoader parent = getClass().getClassLoader();
this.classLoader = URLClassLoader.newInstance(urls, parent);
classLoaderMap.put(urls[0], this.classLoader);
}
} catch (MalformedURLException e) {
throw new RuntimeException("Error loading JDBC driver.", e);
}
Expand Down
Loading