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)

猜你喜欢

转载自blog.csdn.net/BetrayFree/article/details/88973441