问题记录:使用Connector/J 8.4.0或更高版本创建与服务器的连接可能需要很长时间

更新到Connector/J 9.2.0及以上版本即可

<!-- https://mvnrepository.com/artifact/com.mysql/mysql-connector-j -->
<dependency>
    <groupId>com.mysql</groupId>
    <artifactId>mysql-connector-j</artifactId>
    <version>9.2.0</version>
</dependency>

参考官方修复公告:使用Connector/J 8.4.0或更高版本创建与服务器的连接可能需要很长时间。这是因为Connector/J 8.4.0及更高版本总是对主机IP地址执行反向DNS查找。使用此补丁,仅当使用OpenTetry时才执行查找,在这种情况下需要查找。(错误号115586,错误号36850047)

It might take a long time to create a connection to a server with Connector/J 8.4.0 or later. It was because Connector/J 8.4.0 and later always performed a reverse DNS lookup on the host IP address. With this patch, the lookup is only performed when OpenTelemetry is used, in which case the lookup is required. (Bug #115586, Bug #36850047)

整个原文:

Changes in MySQL Connector/J 9.2.0 (2025-01-21, General Availability)
Version 9.2.0 is a new GA release of MySQL Connector/J. MySQL Connector/J 9.2.0 supersedes 9.1 and is recommended for use on production systems. This release can be used against MySQL Server version 8.0 and later. It supports the Java Database Connectivity (JDBC) 4.2 API, and implements the X DevAPI.

Installation and Compilation Notes

Bugs Fixed

Installation and Compilation Notes
The version requirements for the third-party libraries and tools needed for running and building Connector/J have been updated. See Connector/J Installation and Installing from Source for details. (WL #16558)

Bugs Fixed
On Windows platforms, some tests in the test suite failed when the test databases' names contained uppercase characters. Those tests have now been fixed. (Bug #37272802)

The RPM package for Connector/J distributed by Oracle had a requirement to install the java-headless package, which was a Java 8 package and was really unnecessary for running Connector/J. The requirement has now been removed. (Bug #37125271)

Calling exectueBatch() on a PreparedStatement resets its QueryTimeout value to 0. With this patch, the call no longer changes QueryTimeout. (Bug #21983318)

When the connection properties useServerPrepStmts and useLocalTransactionState were both true and a PreparedStatement was used, a statement rollback would fail. This was because the PreparedStatement always reset the local transaction state. With this fix, Connector/J checks and makes sure that the transaction state is only reset when it should be. (Bug #116318, Bug #37152533)

Behaviors of a few of the DatabaseMetaData methods were inconsistent when handling parameters of identifiers quoted with backticks (`). With this patch, identifiers quoted by backticks are always unquoted when the connection is in non-pedantic mode, but they are always taken as-is (with the backticks escaped as parts of the identifier) when the connection is in pedantic mode. (Bug #116113, Bug #37063728, Bug #63992, Bug #14598872)

It might take a long time to create a connection to a server with Connector/J 8.4.0 or later. It was because Connector/J 8.4.0 and later always performed a reverse DNS lookup on the host IP address. With this patch, the lookup is only performed when OpenTelemetry is used, in which case the lookup is required. (Bug #115586, Bug #36850047)

Calling getMetadata() on a prepared statement with the LIMIT and OFFSET clauses resulted in a SQL syntax error even if the statement was syntactically correct. (Bug #103437, Bug #32807360)

If closeOnCompletion() was enabled on a PreparedStatement, after enabling a streaming ResultSet (for example by calling setFetchSize()), the ResultSet was closed immediately even before any query executions. This patch eliminated the immature closing of the ResultSet, so that queries can be run normally. (Bug #96786, Bug #30280035)

When updateRow() was called after some updates have been performed on a ResultSet, Connector/J tried to update the whole row on the server, resulting in an error when there were columns that the user had no privileges to modify. With this fix, updates are only performed on columns that have been changed in the ResultSet. (Bug #71143, Bug #17967091)

 

posted @ 2025-02-28 14:19  轻寒  阅读(204)  评论(0)    收藏  举报