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)

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值