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 c672fc6 commit 4d55f1c
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,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 @@ -105,6 +110,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 @@ -119,6 +125,16 @@ public void open() throws Exception {
LocalDateTime.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 4d55f1c

Please sign in to comment.