Cannot create PoolableConnectionFactory (Could not create connection to database server.)

严重: Servlet.service() for servlet [SpringMVC] in context with path [/ignore] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.RuntimeException: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server.)
### Cause: java.lang.RuntimeException: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server.)] with root cause
java.lang.NullPointerException

出问题的原因是:升级了mysql8,之前ssm框架使用的mysql-connecter-java5.1.30版本过低,导致报错:Cannot create PoolableConnectionFactory (Could not create connection to database server.)

<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>8.0.11</version>
</dependency>

mysql-connecter-java8.0.12下载:https://download.csdn.net/download/ncdjs1/10577155

另外 jdbc.properties文件中的mysql连接信息也要改变,仅供参考(参数解释可以参考文末连接):

driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/xx_db?useUnicode=true&useSSL=false&serverTimezone=GMT&characterEncoding=utf8
username=root
password=123456

参考:http://www.cnblogs.com/alsf/p/9346921.html


846 Clicks !