diff --git a/java-extensions/jdbc-bridge/src/main/java/com/starrocks/jdbcbridge/JDBCScanner.java b/java-extensions/jdbc-bridge/src/main/java/com/starrocks/jdbcbridge/JDBCScanner.java index ae7fb45505acf..83e8b7f9d174d 100644 --- a/java-extensions/jdbc-bridge/src/main/java/com/starrocks/jdbcbridge/JDBCScanner.java +++ b/java-extensions/jdbc-bridge/src/main/java/com/starrocks/jdbcbridge/JDBCScanner.java @@ -60,9 +60,9 @@ public JDBCScanner(String driverLocation, JDBCScanContext scanContext) { } public void open() throws Exception { - String key = scanContext.getUser() + "/" + scanContext.getJdbcURL(); + String cacheKey = computeCacheKey(scanContext.getUser(), scanContext.getPassword(), scanContext.getJdbcURL()); URL driverURL = new File(driverLocation).toURI().toURL(); - DataSourceCache.DataSourceCacheItem cacheItem = DataSourceCache.getInstance().getSource(key, () -> { + DataSourceCache.DataSourceCacheItem cacheItem = DataSourceCache.getInstance().getSource(cacheKey, () -> { ClassLoader classLoader = URLClassLoader.newInstance(new URL[] {driverURL}); Thread.currentThread().setContextClassLoader(classLoader); HikariConfig config = new HikariConfig(); @@ -116,6 +116,10 @@ public void open() throws Exception { } } + private static String computeCacheKey(String username, String password, String jdbcUrl) { + return username + "/" + password + "/" + jdbcUrl; + } + private static final Set> GENERAL_JDBC_CLASS_SET = new HashSet<>( Arrays.asList(Boolean.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class, BigInteger.class, BigDecimal.class, java.sql.Date.class, Timestamp.class, LocalDate.class,