Browse Source

Merge pull request #5029 in CORE/base-third from release/11.0 to feature/x

* commit '3318c402a75ce0dd42a6fd6953f21224caf202e1':
  REPORT-66916 fix:使用自定义mysql8驱动,连接失败
feature/x
superman 3 years ago
parent
commit
985f15d6cd
  1. 12
      fine-druid/src/main/java/com/fr/third/alibaba/druid/util/MySqlUtils.java

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

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

Loading…
Cancel
Save