mybatis遇到問題解決方法---- mysql的時區錯誤問題

框架的學習是需要不斷的融合實踐的,實踐總是要說錯誤的,下面咱們就來看一下新的錯誤類型--時區錯誤。

當然在這之前,我是不知道有這種問題的,指到我的mybatis遇到了下面這個問題:Error querying database

### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not getJDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!

### The error may exist in com/wj/mapper/UserLoginMapper.xml

### The error may involve com.wj.mapper.UserLoginMapper.selectByName

### The error occurred while executing a query

### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!

這個是什麼呢?爲什麼會查詢錯誤呢?當你檢查了下面一行的配置文件UserLoginMapper.xml,發現你的驅動,你的密碼,你的賬號都是正確的,但是就是查不了數據庫,這是一種時區錯誤了,現在我們用的是東八區,所以要在mysql中設置一下。步驟如下:

首先找到navicat的導航欄中工具--->命令行界面

然後輸入這一段代碼:

mysql> set global time_zone = '+8:00';
Query OK, 0 rows affected

mysql> commit;
Query OK, 0 rows affected

mysql> 

 

這個時候問題就解決了。

下面附上事故現場:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is 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: Connections could not be acquired from the underlying database!
### The error may exist in com/wj/mapper/UserLoginMapper.xml
### The error may involve com.wj.mapper.UserLoginMapper.selectByName
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

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