Add support for mysql 8.0.xx driver

From 8.0.11 the driver is changed to com.mysql.cj.jdbc.JdbcConnection, so try loading it again when com.mysql.cj.api.conf.PropertySet loaded failed.
This commit is contained in:
John Huang
2018-08-07 12:28:29 +08:00
committed by GitHub
parent b3572b7601
commit 7ef5c74aa1
@@ -108,9 +108,22 @@ public class MySqlUtils {
if (method_6_getValue == null && !method_6_getValue_error) {
try {
class_6_connection = Class.forName("com.mysql.cj.api.jdbc.JdbcConnection");
method_6_getPropertySet = class_6_connection.getMethod("getPropertySet");
method_6_getBooleanReadableProperty = Class.forName("com.mysql.cj.api.conf.PropertySet").getMethod("getBooleanReadableProperty", String.class);
method_6_getValue = Class.forName("com.mysql.cj.api.conf.ReadableProperty").getMethod("getValue");
} catch (Throwable t) {
}
try {
// maybe 8.0.11 or higher version, try again with com.mysql.cj.jdbc.JdbcConnection
if (class_6_connection == null) {
class_6_connection = Class.forName("com.mysql.cj.jdbc.JdbcConnection");
method_6_getPropertySet = class_6_connection.getMethod("getPropertySet");
method_6_getBooleanReadableProperty = Class.forName("com.mysql.cj.conf.PropertySet").getMethod("getBooleanReadableProperty", String.class);
method_6_getValue = Class.forName("com.mysql.cj.conf.ReadableProperty").getMethod("getValue");
}
else {
method_6_getPropertySet = class_6_connection.getMethod("getPropertySet");
method_6_getBooleanReadableProperty = Class.forName("com.mysql.cj.api.conf.PropertySet").getMethod("getBooleanReadableProperty", String.class);
method_6_getValue = Class.forName("com.mysql.cj.api.conf.ReadableProperty").getMethod("getValue");
}
} catch (Exception ex) {
ex.printStackTrace();
method_6_getValue_error = true;