spting整合時數據庫連接錯誤!

錯誤:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.
### The error may exist in file [B:\maven_workspace\seckill\target\classes\mapper\SeckillDao.xml]
### The error may involve org.seckill.dao.SeckillDao.queryById
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.

Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.

 

原因:

mysql版本問題!!!

 

mysql5.x 版本

driver=com.mysql.jdbc.Driver

url=jdbc:mysql://127.0.0.1:3306/seckill?useUnicode=true&characterEncoding=utf8

 

mysql8.x版本

driver=com.mysql.cj.jdbc.Driver

url=jdbc:mysql://localhost:3306/AppStore?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true


 

 

解決方法:

有兩種解決方法:

1.退回到5.x版本,其他配置不變

2.修改jdbc.properties文件和pom.xml文件更改mysql版本與主機對應

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章