数据库连接失败Cannot create PoolableConnectionFactory

报的错误:

Caused by: java.lang.RuntimeException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failure
 
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
    at edu.gzucm.yjsglxt.base.util.TimeSetUtils.getTimeSets(TimeSetUtils.java:52)
    at edu.gzucm.yjsglxt.base.util.TimeSetUtils.(TimeSetUtils.java:22)
    ... 3 more
Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failure
 
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
    at edu.gzucm.yjsglxt.base.util.TimeSetUtils.getTimeSets(TimeSetUtils.java:32)
    ... 4 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure



别人说的错误是数据库配置有错!


在网上找了半天资料,说是配置文件的问题,检查了好多遍,mysql 没问题,url没问题


最后发现是驱动包的问题,果断换成了     mysql2-connector.jar


把原来的驱动包直接删了,OK!  完工!

你可能感兴趣的:(数据库连接失败Cannot create PoolableConnectionFactory)