Skip to content

Commit

Permalink
[BugFix] Fix jdbc catalog change password not effect (#51748)
Browse files Browse the repository at this point in the history
Signed-off-by: Smith Cruise <[email protected]>
(cherry picked from commit acce535)

# Conflicts:
#	java-extensions/jdbc-bridge/src/main/java/com/starrocks/jdbcbridge/JDBCScanner.java
  • Loading branch information
Smith-Cruise authored and mergify[bot] committed Oct 11, 2024
1 parent 6f75c2d commit 06c7a9c
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ 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();
<<<<<<< HEAD
DataSourceCache.DataSourceCacheItem cacheItem = DataSourceCache.getInstance().getSource(key, () -> {
ClassLoader classLoader = URLClassLoader.newInstance(new URL[] {
driverURL,
});
=======
DataSourceCache.DataSourceCacheItem cacheItem = DataSourceCache.getInstance().getSource(cacheKey, () -> {
ClassLoader classLoader = URLClassLoader.newInstance(new URL[] {driverURL});
>>>>>>> acce535baf ([BugFix] Fix jdbc catalog change password not effect (#51748))
Thread.currentThread().setContextClassLoader(classLoader);
HikariConfig config = new HikariConfig();
config.setDriverClassName(scanContext.getDriverClassName());
Expand Down Expand Up @@ -118,6 +123,7 @@ public void open() throws Exception {
}
}

<<<<<<< HEAD
private static final Set<Class<?>> GENERAL_JDBC_CLASS_SET = new HashSet<>(Arrays.asList(
Boolean.class,
Short.class,
Expand All @@ -133,6 +139,16 @@ public void open() throws Exception {
Time.class,
String.class
));
=======
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,
LocalDateTime.class, Time.class, String.class));
>>>>>>> acce535baf ([BugFix] Fix jdbc catalog change password not effect (#51748))

private boolean isGeneralJDBCClassType(Class<?> clazz) {
return GENERAL_JDBC_CLASS_SET.contains(clazz);
Expand Down

0 comments on commit 06c7a9c

Please sign in to comment.