JDBC connection problems encountered MySQL record

gitpage blog address https://xisynotz.xyz

1. driver package version of the problem! !

Will continue on the database connection is not being given, but it seems there is no obvious prompt.

Database using a Mysql8 version, but works inside the driver package mysql version is 5.1.37. Simply modify the driver package for the 8.0.11 version.

And drive package also changed, from the original: /generatorSqlmapCustom/lib/mysql-connector-java-5.1.28-bin.jar

Replaced by: mysql-connector-java-8.0.11.jar

Note Mysql8.0 driving connection JDBC driver class for a name Class.forName ( "com.mysql.cj.jdbc.Driver");

2.Establishing SSL connection without server’s identity verification is not recommended.

stackoverflow

Plus useSSL = false

con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test?useSSL=false", "root", "123456");

3. The number of connections beyond

'root' has exceeded the 'max_questions' resource (current value: 2) 

Under normal circumstances, the user is not going to modify this value is 0, then there is no limit, but I owe hand, modify this value.

Resolve this problem, you should use other super user login privileges, simply edit the value, then refresh permission.

4. Time Zone Problems

java.sql.SQLException: The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

Plus serverTimezone = GMT

con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test?useSSL=true&serverTimezone=GMT", "root", "123456");

5.MySQL 8.0 Public Key Retrieval is not allowed

The easiest solution is to add back connection allowPublicKeyRetrieval = true

Documents explanation given is:

If the customer uses sha256_password authentication, a password must be used during transmission protection TLS protocol, but if the RSA public key is not available, use the public key provided by the server; ServerRSAPublicKeyFile specified by the RSA public key server, or in connection AllowPublicKeyRetrieval = True parameters to allow the client to obtain the public key from the server; it should be noted that AllowPublicKeyRetrieval = True could result in malicious attacks through an intermediary agent acquisition (MITM) to clear-text passwords, so is off by default and must be explicitly turned on.

Guess you like

Origin blog.csdn.net/saber_jk/article/details/92697654
Recommended