admin管理员组文章数量:1642471
MYSQL使用的版本
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.11</version>
</dependency>
异常一:
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.
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.
原因:
mysl8.0以上版本数据库驱动类改啦,要配置com.mysql.cj.jdbc.Driver
Mysql8.0以下版本 驱动类配置为:com.mysql.jdbc.Driver
在使用mysql的jdbc驱动最新版(6.0+)版本时,数据库和系统时区差异引起的问题
第二个原因:
在使用mysql的jdbc驱动最新版时,数据库和系统时区差异引起的问题。
解决办法:
1.一种是降版本,并不推荐,如果需要降版本5.5版本可以满足基本需要;
2.还有一种是在jdbc连接的url后面加上serverTimezone=UTC或GMT即可,如果需要指定使用gmt+8时区,需要写成GMT%2B8,不然可能会报错误,解析为空
例子:
url: jdbc:mysql://localhost:3306/base?serverTimezone=GMT&useSSL=false&useUnicode=true&characterEncoding=utf8
解决:
修改配置的驱动类,改成com.mysql.cj.jdbc.Driver
异常二:
java.sql.SQLNonTransientConnectionException: Cannot load connection class because of underlying exception: com.mysql.cj.exceptions.WrongArgumentException: Malformed database URL, failed to parse the main URL sections.
原因:
url参数配置不正确,请检查参数是否正确
版权声明:本文标题:配置数据库驱动遇到的异常问题记录 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1729339574a1197370.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论