Skip to content

Commit

Permalink
Fix GH-2147 by adding an extra check to make sure we don't remove the…
Browse files Browse the repository at this point in the history
… wrong driver from the DriverManager (#2148)

Fixes #2147
  • Loading branch information
Vankka committed Nov 7, 2021
1 parent fe0adf5 commit b680bc0
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ private void unloadMySQLDriver() {
Enumeration<Driver> drivers = DriverManager.getDrivers();
while (drivers.hasMoreElements()) {
Driver driver = drivers.nextElement();
if ("com.mysql.cj.jdbc.Driver".equals(driver.getClass().getName())) {
Class<?> driverClass = driver.getClass();
// Checks that it's from our class loader to avoid unloading another plugin's/the server's driver
if ("com.mysql.cj.jdbc.Driver".equals(driverClass.getName()) && driverClass.getClassLoader() == driverClassLoader) {
try {
DriverManager.deregisterDriver(driver);
} catch (SQLException e) {
Expand Down

0 comments on commit b680bc0

Please sign in to comment.