From 9b1d4b995d32278328311fafb61aa0dcaaef82db Mon Sep 17 00:00:00 2001 From: Petr Ilin Date: Sun, 25 Dec 2022 03:38:56 +0300 Subject: MySQL external library fix --- .../java/net/elytrium/limboauth/dependencies/DatabaseLibrary.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/elytrium/limboauth/dependencies/DatabaseLibrary.java b/src/main/java/net/elytrium/limboauth/dependencies/DatabaseLibrary.java index 3a8a070..122db78 100644 --- a/src/main/java/net/elytrium/limboauth/dependencies/DatabaseLibrary.java +++ b/src/main/java/net/elytrium/limboauth/dependencies/DatabaseLibrary.java @@ -64,7 +64,8 @@ public enum DatabaseLibrary { ), MYSQL( BaseLibrary.MYSQL, - (classLoader, dir, jdbc, user, password) -> fromDriver(classLoader.loadClass("com.mysql.cj.jdbc.Driver"), jdbc, user, password, true), + (classLoader, dir, jdbc, user, password) + -> fromDriver(classLoader.loadClass("com.mysql.cj.jdbc.NonRegisteringDriver"), jdbc, user, password, true), (dir, hostname, database) -> "jdbc:mysql://" + hostname + "/" + database ), @@ -130,8 +131,9 @@ public enum DatabaseLibrary { Object driver = legacyConstructor.newInstance(); - if (!register) { - DriverManager.deregisterDriver((Driver) driver); + DriverManager.deregisterDriver((Driver) driver); + if (register) { + DriverManager.registerDriver((Driver) driver); } Method connect = connectionClass.getDeclaredMethod("connect", String.class, Properties.class); -- cgit