Browse Source

Merge pull request #5065 in CORE/base-third from final/11.0 to release/11.0

* commit 'faf37bda29cfcfd48c8f22b699f93e00fd928673':
  REPORT-67030 fix: mysql数据连接无法正常连接
bugfix/KERNEL-11409-jackson
superman 3 years ago
parent
commit
383ec07312
  1. 15
      fine-druid/src/main/java/com/fr/third/alibaba/druid/util/MySqlUtils.java

15
fine-druid/src/main/java/com/fr/third/alibaba/druid/util/MySqlUtils.java

@ -386,16 +386,15 @@ public class MySqlUtils {
public static long getLastPacketReceivedTimeMs(Connection conn) throws SQLException {
if (!class_connectionImpl_Error) {
if (conn == null) {
return -1;
}
try {
//REPORT-66916 这里之前获取到的是lib下的mysql5实现,而不是自定义mysql8驱动的实现
String className = conn.getClass().getName();
class_connectionImpl = Utils.loadClass(className);
if (className.equals("com.mysql.cj.MysqlConnection")) {
mysqlJdbcVersion6 = false;
class_connectionImpl = Utils.loadClass("com.mysql.jdbc.MySQLConnection");
if (class_connectionImpl == null || class_connectionImpl.getClassLoader() != conn.getClass().getClassLoader()) {
class_connectionImpl = Utils.loadClass("com.mysql.cj.MysqlConnection");
if (class_connectionImpl != null) {
mysqlJdbcVersion6 = true;
}
}
} catch (Throwable error) {
class_connectionImpl_Error = true;
}
@ -412,7 +411,7 @@ public class MySqlUtils {
return -1;
}
if (getIdleFor == null && !getIdleForError) {
if (!getIdleForError) {
try {
getIdleFor = classJdbc.getMethod("getIdleFor");
getIdleFor.setAccessible(true);

Loading…
Cancel
Save