• druid数据源配置


    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
    <property name="url" value="${datasource.url}" />
    <property name="username" value="${datasource.name}" />
    <property name="password" value="${datasource.password}" />
    <property name="connectionProperties" value="config.decrypt=true" />
    <property name="filters" value="config,log4j" />
    <property name="maxActive" value="${datasource.maxActive}" />
    <property name="initialSize" value="${datasource.initialiSize}" />
    <property name="maxWait" value="60000" />
    <property name="minIdle" value="1" />
    <property name="timeBetweenEvictionRunsMillis" value="60000" />
    <property name="minEvictableIdleTimeMillis" value="300000" />
    <property name="validationQuery" value="SELECT 'x' from dual " />
    <property name="testWhileIdle" value="true" />
    <property name="testOnBorrow" value="false" />
    <property name="testOnReturn" value="false" />
    <property name="poolPreparedStatements" value="true" />
    <property name="maxPoolPreparedStatementPerConnectionSize" value="20" />
    </bean>

    connectionProperties:配置连接的一些属性,这里配置的config.decrypt=true,表示提供的密码是加密过的

    filters:就是一个拦截器,可配置监控、日志等

    maxActive:最大连接数个数

    initialSize:初始化连接数个数

    minIdle:空闲的连接数个数

    maxWait:获取连接最大等待时间

    timeBetweenEvictionRunsMillis:检测连接时间,单位毫秒

    minEvictableIdleTimeMillis:检测未关闭连接大于该值则关闭连接,单位毫秒

    validationQuery:系统启动时通过该sql语句验证数据库是否可用,例如oracle用SELECT 'x' from dual,mysql用SELECT 'x' 

    testWhileIdle:启用空闲连接检测,以便回收

    testOnBorrow:从连接池获取连接时,是否检测连接可用性,开启性能会有些许影响

    testOnReturn:释放连接到连接池时,是否检测连接可用性,开启性能会有些许影响

    poolPreparedStatements:开启psCache缓存,oracle请设置为true,非oracle请设置为false

    maxPoolPreparedStatementPerConnectionSize:最大缓存数,非oracle请设置为0

  • 相关阅读:
    谷歌大规模机器学习:模型训练、特征工程和算法选择 (32PPT下载)
    (转) 深度强化学习综述:从AlphaGo背后的力量到学习资源分享(附论文)
    (转) Supercharging Style Transfer
    Summary on deep learning framework --- TensorFlow
    (转) How a Kalman filter works, in pictures
    Torch 两个矩形框重叠面积的计算 (IoU between tow bounding box)
    C、C++基础和编程风格 (转)
    Linux && shell
    求最短路径的条数
    一个链表中包含环,请找出该链表的环的入口结点。
  • 原文地址:https://www.cnblogs.com/jager/p/5384436.html
Copyright © 2020-2023  润新知