zoukankan      html  css  js  c++  java
  • 严重: testWhileIdle is true, validationQuery not set 使用Druid连接池报错处理

    环境:  JDK8  、MYSQL 5.7.17 、Spring boot 2.1.6  、Druid - 1.1.10 的jar包;

    使用 druid-1.1.10.jar 报错如下;

    3月 25, 2020 7:55:37 下午 com.alibaba.druid.pool.DruidDataSource error
    严重: testWhileIdle is true, validationQuery not set
    3月 25, 2020 7:55:50 下午 com.alibaba.druid.pool.DruidDataSource info
    信息: {dataSource-1} inited

    在properties配置文件下添加一些配置;

    filters=stat
    initialSize=2
    maxActive=300
    maxWait=60000
    timeBetweenEvictionRunsMillis=60000
    minEvictableIdleTimeMillis=300000
    validationQuery=SELECT 1
    testWhileIdle=true
    testOnBorrow=true
    testOnReturn=false
    poolPreparedStatements=false
    maxPoolPreparedStatementPerConnectionSize=200

    完整配置如下:

    spring:
      application:
        name: test
      datasource:
        url: jdbc:mariadb://127.0.0.1:3306/test?characterEncoding=utf-8
        driver-class-name: org.mariadb.jdbc.Driver
        type: com.alibaba.druid.pool.DruidDataSource
        druid:
          initial-size: 15
          min-idle: 15
          max-active: 200
          max-wait: 60000
          time-between-eviction-runs-millis: 60000
          min-evictable-idle-time-millis: 300000
          validation-query: select 1
          test-while-idle: true
          test-on-borrow: true
          test-on-return: false
          pool-prepared-statements: false
          connection-properties: false
          filters: stat,slf4j
          filter:
            slf4j:
              connection-log-enabled: false
              data-source-log-enabled: false
              result-set-log-enabled: false
              statement-log-enabled: true
          web-stat-filter:
            enabled: false
          log-abandoned: true
          remove-abandoned: true
          remove-abandoned-timeout: 60
          keep-alive: true
          max-pool-prepared-statement-per-connection-size: 10

    再次运行;

    3月 25, 2020 8:14:13 下午 com.alibaba.druid.pool.DruidDataSource info
    信息: {dataSource-1} inited

    报错2;

    信息: {dataSource-1} inited

    这是日志信息,没有错Druid采用了日志打印机制,这不是报错;

    连接池采用了懒加载,真正用到的时候才初始化;

     

  • 相关阅读:
    poj 1466 Girls and Boys (最大独立集)
    hdu 3667 Transportation (拆边 ,最小费用流)
    poj 3487 The Stable Marriage Problem (稳定婚姻 GaleShapley算法 )
    ZOJ Problem Set 1239 (最小点覆盖 )
    poj 2060 Taxi Cab Scheme (最小路径覆盖)
    poj 2226 Muddy Fields (最小点覆盖)
    hdu 1281 棋盘游戏 (二分图)
    hdu 3666 THE MATRIX PROBLEM (差分约束)
    poj 1325 Machine Schedule (最小点覆盖)
    ORACLE导入导出
  • 原文地址:https://www.cnblogs.com/rinack/p/13610338.html
Copyright © 2011-2022 走看看