Hikaricp 替换现有的数据库连接池也是很方便的 没有时间去测试 现贴出简单的配置
如果使用spring,只需要简单的替换
<bean id="hikariDataSource"
class="com.zaxxer.hikari.HikariDataSource" destroy-method="shutdown">
<constructor-arg>
<bean class="com.zaxxer.hikari.HikariConfig">
<property name="driverClassName" value="${hikaricp.jdbc.driverClassName}"/>
<property name="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&characterEncoding=UTF-8
hikaricp.quratz_jdbc.url=jdbc:mysql://127.0.0.1:3306/quartz?useUnicode=true&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)
hikaricp.maxLifetime = 1800000
#池连接数量
hikaricp.maximumPoolSize =100
hikaricp.minimumIdle =100
是否真正好用 为开发者带来便利还有带长期的测试 本身这个项目年限也没有多久更多信息 :