Hikaricp simple to use

2017/09/18
Hikaricp simple to use

Hikaricp replaces the existing database connection pool is not very convenient time to test a simple configuration now posted
If spring, simply replacing
<the bean ID = "hikariDataSource"
          class = "com.zaxxer.hikari.HikariDataSource" the destroy = -method "the shutdown">
        <constructor-Arg>
            <the bean class = "com.zaxxer.hikari.HikariConfig">
                <Property name = "driverClassName" value = "$ {hikaricp.jdbc.driverClassName}" />
                <Property name = "the jdbcUrl" value = "$ {hikaricp.url}" />
                <Property name = "username" value = "$ {hikaricp.username}" />
                <Property name = "password" value = "$ {hikaricp.password } "/>
                <property name="connectionTestQuery" value="${hikaricp.connectionTestQuery}"/>
                <property name="connectionTimeout" value="${hikaricp.connectionTimeout}"/>
                <property name="idleTimeout" value="${hikaricp.idleTimeout}"/>
                <property name="maxLifetime" value="${hikaricp.maxLifetime}"/>
                <property name="maximumPoolSize" value="${hikaricp.maximumPoolSize}"/>
                <property name="minimumIdle" value="${hikaricp.minimumIdle}"/>
            </bean>
        </constructor-arg>
    </bean>

引入的properties文件:
#HikariDataSource config
hikaricp.jdbc.driverClassName=com.mysql.jdbc.Driver
hikaricp.url= jdbc:mysql://127.0.0.1:3306/dcserver38?useUnicode=true&amp;characterEncoding=UTF-8
hikaricp.quratz_jdbc.url=jdbc:mysql://127.0.0.1:3306/quartz?useUnicode=true&amp;characterEncoding=UTF-8
hikaricp.username=root
hikaricp.password=123456
hikaricp.connectionTestQuery= SELECT 1
hikaricp.connectionTimeout =    30000
#This property controls the maximum amount of time (in milliseconds)\
#   that a connection is allowed to sit idle in the pool. Whether a connection is retired \
#  as idle or not is subject to a maximum variation of +30 seconds, and average variation of +15 seconds.\
#   A connection will never be retired as idle before this timeout. A value of 0 means that idle connections \
#  are never removed from the pool. Default: 600000 (10 minutes)
hikaricp.idleTimeout =  600000
#This property controls the maximum lifetime of a connection in the pool. When a connection reaches this timeout, \
#  even if recently used, it will be retired from the pool. An in-use connection will never be retired, \
#  only when it is idle will it be removed. We strongly recommend setting this value, and using something \
#  reasonable like 30 minutes or 1 hour. A value of 0 indicates no maximum lifetime (infinite lifetime), s\
#  ubject of course to the idleTimeout setting. Default: 1800000 (30 minutes)
= 1800000 Hikaricp.MaxLifetime
# pond连接quantity
Hikaricp.MaximumPoolSize = 100
Hikaricp.MinimumIdle = 100
 

Guess you like

Origin blog.csdn.net/u012432389/article/details/93623376