java mybtais 连接不上mysql8 :Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
原创    helloworld    发表于:2018-10-26 14:09:19
  阅读 :99   收藏   编辑

mysql升级至8后,数据库用户名、密码、权限都正确,依然连接不上

错误如下:

Caused by: java.lang.RuntimeException: java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.github.pagehelper.PageHelper.getUrl(PageHelper.java:287)
at com.github.pagehelper.PageHelper.getSqlUtil(PageHelper.java:310)
at com.github.pagehelper.PageHelper.initSqlUtil(PageHelper.java:266)
at com.github.pagehelper.PageHelper.intercept(PageHelper.java:253)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:60)
at com.sun.proxy.$Proxy48.query(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
... 63 more
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:692)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:140)
at com.github.pagehelper.PageHelper.getUrl(PageHelper.java:284)
... 69 more
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1469)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:644)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:554)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:758)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:685)
... 71 more

解决办法

  • 第一步:升级jdk为1.8

  • 第二步:升级mysql驱动

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.11</version>
</dependency>
  • 第三步:更新jdbc.driverClassName和jdbc.url

jdbc.driverClassName=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/db_sms?useSSL=false&characterEncoding=utf8&allowMultiQueries=true




评论
条评论