java.sql.SQLException: Unknown system variable 'query_cache_size'解决方法

这个问题是因为你的MySQL Connector的jar包和数据库不匹配造成的。
我的数据是是使用MySQL8.x的版本,但MySQL Connector使用的jar包是6.x的,所以会报上面的错误。
解决方法就是去maven仓库下载与数据库版本对应的jar包,下载地址:http://mvnrepository.com/artifact/mysql/mysql-connector-java

已标记关键词 清除标记
<font size="4" >在进行DBCP没有错误而在尝试c3p0链接mysql的时候总是出现这几个问题,之前一直以为是版本的问题就把 mysql的版本和驱动版本都更新到最新,可是还是一样的错误,然后又调大的xml的配置可还是同样的问题<font/> ``` 警告: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@605b17a1 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: java.sql.SQLException: Unknown system variable 'query_cache_size' .... 警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@48140564 is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests. java.sql.SQLException: Connections could not be acquired from the underlying database! ... Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source. ... Caused by: java.sql.SQLException: Unknown system variable 'query_cache_size' ... 警告: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@48140564 is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests. ``` 配置信息: ``` <default-config> <!-- 基本配置 --> <property name="driverClass">com.mysql.cj.jdbc.Driver</property> <property name="jdbcUrl">jdbc:mysql://127.0.0.1:3306/day07?useSSL=false&serverTimezone=UTC</property> <property name="user">root</property> <property name="password">123456</property> <!--扩展配置--> <property name="checkoutTimeout">50000</property> <property name="idleConnectionTestPeriod">30</property> <property name="initialPoolSize">10</property> <property name="maxIdleTime">50</property> <property name="maxPoolSize">5000</property> <property name="minPoolSize">10</property> <property name="maxStatements">200</property> </default-config> ```
©️2020 CSDN 皮肤主题: 成长之路 设计师:Amelia_0503 返回首页