JDBC连接报错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 conf
When connecting to the MySQL service, directly specify the time zone as UTC
reason:
This error is usually caused by inconsistent time zone configuration between the database server and the JDBC driver. This error is thrown when the database server cannot recognize or represent more than one time zone.
In some cases, the JDBC driver cannot determine the time zone setting of the database server, so the time zone needs to be specified explicitly. This can be achieved by adding parameters to the connection string serverTimezone
.
original connection
"jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8
Change to the current one: (In short, the key is to add serverTimezone=UTC)
"jdbc:mysql://localhost:3306/test?characterEncoding=utf8&serverTimezone=UTC";
can