RT↑
使用 Druid 的时候 反馈连接数据库超时异常
配置如下:
jdbc.url=jdbc:mysql:replication://127.0.0.1:3306,127.0.0.1:3307/hmp?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="filters" value="stat"/>
<property name="maxActive" value="18"/>
<property name="initialSize" value="2"/>
<property name="maxWait" value="60"/>
<property name="minIdle" value="4"/>
<property name="timeBetweenEvictionRunsMillis" value="60000"/>
<property name="minEvictableIdleTimeMillis" value="300000"/>
<property name="validationQuery" value="SELECT 'x'"/>
<property name="testWhileIdle" value="true"/>
<property name="testOnBorrow" value="false"/>
<property name="testOnReturn" value="false"/>
<property name="maxOpenPreparedStatements" value="20"/>
<property name="removeAbandoned" value="true"/>
<!-- 打开 removeAbandoned 功能 -->
<property name="removeAbandonedTimeout" value="1800"/>
<!-- 1800 秒,也就是 30 分钟 -->
<property name="logAbandoned" value="true"/>
<!-- 关闭 abanded 连接时输出错误日志 -->
</bean>