闲着无聊用idea写了一下jdbc用了最新的mysql-connector-java-8.0.11突然发现编码没有异常但是运行时出现了两个异常,如下

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

字面意思 mysqljdbc . driver。这是被弃用的。新的驱动类是“com.mysql.cjdbc.driver”。驱动程序通过SPI自动注册,而手动加载类通常是不必要的。

那么我只需要把 com.mysql.jdbc.Driver 改为com.mysql.cj.jdbc.Driver 即可

java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time 

 

从错误上看应该是时区的错误,因此只需要设置为你当前系统时区即可

 

static final  String DB_URL="jdbc:mysql://localhost:3306/csm"+"?serverTimezone=GMT%2B8";
加上?serverTimezone=GMT%2B8" 即可  GMT%2B8代表: 东八区

 

GMT%2B8代表是东八区

 

10-04 10:18