Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.1.1, 2.2.0
-
None
Description
Debugging my code, i Found that fastFailValidation is always false because of this Constructor:
org.apache.commons.dbcp2.PoolableConnection
/** * * @param conn my underlying connection * @param pool the pool to which I should return when closed * @param jmxName JMX name */ public PoolableConnection(Connection conn, ObjectPool<PoolableConnection> pool, ObjectName jmxName) { this(conn, pool, jmxName, null, false); }
Notice that 4th and 5th params are for fastFailValidation. It will always be false. (and null for sql codes)
My Pool definition (spring):
<bean id="dataSource" class="org.apache.commons.dbcp2.managed.BasicManagedDataSource" destroy-method="close"> <property name="transactionManager" ref="jbossTransactionManager"/> <property name="driverClassName" value="xxx" /> <property name="url" value="xxx" /> <property name="username" value="xxx" /> <property name="password" value="xxx" /> <property name="initialSize" value="0" /> <property name="defaultAutoCommit" value="false" /> <property name="maxTotal" value="1" /> <property name="maxIdle" value="0" /> <property name="maxWaitMillis" value="5000" /> <property name="testOnBorrow" value="true" /> <property name="testOnReturn" value="false" /> <property name="fastFailValidation" value="true" /> <property name="validationQuery" value="select 1 go" /> </bean>