Skip to content

Commit 3d56037

Browse files
authored
Move JDBC driver loading to static initializer (#293)
* Optimize JDBC driver loading with thread-safe initialization and reduce log * Move JDBC driver loading to static initializer * remove unused code * remove unused code
1 parent 4491cfe commit 3d56037

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/com/alipay/oceanbase/rpc/location/LocationUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public class LocationUtil {
6060
.getLogger(LocationUtil.class);
6161
static {
6262
ParserConfig.getGlobalInstance().setSafeMode(true);
63+
loadJdbcDriver();
6364
}
6465

6566
private static final String OB_VERSION_SQL = "SELECT /*+READ_CONSISTENCY(WEAK)*/ OB_VERSION() AS CLUSTER_VERSION;";
@@ -298,7 +299,6 @@ private static String formatObServerUrl(ObServerAddr obServerAddr, long connectT
298299
*/
299300
private static Connection getMetaRefreshConnection(String url, ObUserAuth sysUA)
300301
throws ObTableEntryRefreshException {
301-
loadJdbcDriver();
302302

303303
try {
304304
return DriverManager.getConnection(url, sysUA.getUserName(), sysUA.getPassword());
@@ -312,8 +312,8 @@ private static void loadJdbcDriver() {
312312
try {
313313
Class.forName("com.mysql.cj.jdbc.Driver");
314314
return;
315-
} catch (ClassNotFoundException e) {
316-
RUNTIME.info("Class 'com.mysql.cj.jdbc.Driver' not found, "
315+
} catch (ClassNotFoundException ignored) {
316+
RUNTIME.debug("Class 'com.mysql.cj.jdbc.Driver' not found, "
317317
+ "try to load legacy driver class 'com.mysql.jdbc.Driver'");
318318
}
319319

0 commit comments

Comments
 (0)