admin管理员组文章数量:1642430
小白学习MyBatis遇到的报错,都是小问题,记录一下供参考。
控制台报错如下:
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.
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: 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.
### The error may exist in com\lyh\entity\UsersMapper.xml
### The error may involve test.findUserByName
### The error occurred while executing a query
### Cause: java.sql.SQLException: The server time zone value '�й���ʱ��'
错误代码:
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/bookstore"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</dataSource>
这里面我的connector.jar包版本是8.0.16
两个可以找出的明显错误分别是:
1.mysql.jdbc.Driver驱动弃用了,应是jar包版本比较高。
2.时区异常
解决方案:
1.按照提示更换新驱动
2.在数据库名后面添加时区设置
改正后代码:
<dataSource type="POOLED">
<property name="driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/bookstore?serverTimezone=UTC"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</dataSource>
改正后运行结果:
成功运行。
本文标签: 解决方案mysqlclassloadingjdbc
版权声明:本文标题:Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver class...解决方案 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1729339989a1197418.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论