当前位置:网站首页>Common errors when mysql8 connects through JDBC

Common errors when mysql8 connects through JDBC

2022-06-12 02:22:00 Procedural ape (siege lion)

1. mysql8 perform jdbc Connect to the times The server time zone value '' is unrecognized ...

Error as title , The above cannot identify the time zone settings or multiple time zones .

terms of settlement , It can be in jdbc url Add time zone settings in , Another way is to mysql Set time zone .

mysql> set global time_zone='+8:00';
Query OK, 0 rows affected

After setting , The report goes wrong .

2. mysql8 perform jdbc Connect to the times java.math.BigInteger cannot be cast to java.lang.Long

The reason is that mysql 5.1.27 Drive connection for mysql 8, Modified to 8.0.11.

<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.11</version>
        </dependency>

3. mysql8 When no global time zone is specified , You need to connect to the database url You need to specify

jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=utf8&useSSL=true&serverTimezone=GMT%2b8

The parameters are serverTimezone=GMT%2b8 That is, specify the time zone as GMT+8.

原网站

版权声明
本文为[Procedural ape (siege lion)]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203011150484328.html