From d6c23c8018c4e4acd39a530ea5503d83172230c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E9=93=81?= Date: Wed, 7 Oct 2020 00:35:13 +0800 Subject: [PATCH] bug fixed for mysql xa support --- .../com/alibaba/druid/util/MySqlUtils.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/alibaba/druid/util/MySqlUtils.java b/src/main/java/com/alibaba/druid/util/MySqlUtils.java index 59deb753f8..cf06eb08b1 100644 --- a/src/main/java/com/alibaba/druid/util/MySqlUtils.java +++ b/src/main/java/com/alibaba/druid/util/MySqlUtils.java @@ -122,8 +122,24 @@ public class MySqlUtils { 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"); + Class propertySetClass = Class.forName("com.mysql.cj.conf.PropertySet"); + + NoSuchMethodException noSuchMethodException = null; + try { + method_6_getBooleanReadableProperty = propertySetClass + .getMethod("getBooleanReadableProperty", String.class); + method_6_getValue = Class.forName("com.mysql.cj.conf.ReadableProperty") + .getMethod("getValue"); + } catch (NoSuchMethodException error) { + noSuchMethodException = error; + } + if (method_6_getBooleanReadableProperty == null) { + method_6_getBooleanReadableProperty = propertySetClass + .getMethod("getBooleanProperty", String.class); + method_6_getValue = Class.forName("com.mysql.cj.conf.RuntimeProperty") + .getMethod("getValue"); + } + } else { method_6_getPropertySet = class_6_connection.getMethod("getPropertySet");