maven SQL 时区 bug(基本都是视频教程过时而导致的问题)

时区错误

报错信息: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.

解决:把配置文件改为URL=jdbc:mysql://localhost:3306/elm?characterEncoding=utf-8&serverTimezone=CTT

@Override注解报红出现Undo Set language level to 6 - @Override in interfaces?

该问题的原因是java工程JDK的Language level 版本过低导致,@oveeide注解是在jdk6之后出来的,而我的工程中module中jdk Language level 用的是5,因此报红。

Information:javac 1.8.0_181 was used to compile java sources

报错原因:因为Idea中已经配置了jdk 1.8.0_181的版本,但Idea有几个地方的jdk版本被默认为1.6版本的jdk。

解决:

  • 以下的全都要一致,均为1.8

    img0

    img1

连接数据库出现问题

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

Caused by: javax.net.ssl.SSLException: Software caused connection abort: recv failed

Suppressed: java.net.SocketException: Software caused connection abort: socket write error

解决:

在配置文件的URL结尾加上  &autoReconnect=true
即URL=jdbc:mysql://localhost:3306/elm?characterEncoding=utf-8&serverTimezone=CTT&autoReconnect=true

报告SQL语法错误

java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'selet * from admin where adminName='wanglei' and password='123'' at line 1

错误 selet * from admin where adminName='wanglei' and password='123'

正确 select * from admin where adminName='wanglei' and password='123'

posted @ 2022-10-03 13:00  mykaneki  阅读(77)  评论(0编辑  收藏  举报