Dell.Chen
2020-02-25 16:13
采纳率: 100%
浏览 1.8k
已采纳

用c3p0链接mysql总是出现Unknown system variable 'query_cache_size'

在进行DBCP没有错误而在尝试c3p0链接mysql的时候总是出现这几个问题,之前一直以为是版本的问题就把
mysql的版本和驱动版本都更新到最新,可是还是一样的错误,然后又调大的xml的配置可还是同样的问题

警告: 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&amp;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> 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • 已采纳

    好歹配置信息发错来,你这个错误是数据库链接配置有错误。发出来,看看就知道了

    已采纳该答案
    打赏 评论
  • threenewbee 2020-02-25 16:24
    打赏 评论
  • walterfilan 2020-03-15 14:38

    更新:
    我把驱动换成5.1.48后就没报错了,但是我自己的数据库明明是8.0.12,怎么都没想到竟然要用5.1.48!


    请问你最后解决了吗。我也是这个问题,之前单元测试的时候提示过了,我已经把驱动改成了8.0.11,测试通过;后来接口测试的时候又出现Unknown system variable 'query_cache_size',把8.0.11到8.0.19都用遍了还是不行,同时单元测试里面插入数据是没问题的。卡了两天了

    打赏 评论

相关推荐 更多相似问题