Skip to content

Commit

Permalink
[BugFix] Fix jdbc catalog change password not effect (StarRocks#51748)
Browse files Browse the repository at this point in the history
Signed-off-by: Smith Cruise <chendingchao1@126.com>
  • Loading branch information
Smith-Cruise authored Oct 11, 2024
1 parent b317081 commit acce535
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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<Class<?>> 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,
Expand Down

0 comments on commit acce535

Please sign in to comment.