Spring configuration in applicationcontext.cml for mysql
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://${mySQL.host}/${mySQL.db}" />
<property name="username" value="${mySQL.user}" />
<property name="password" value="${mySQL.pass}" />
<property name="testOnBorrow" value="true"></property>
<property name="validationQuery" value="SELECT 1"></property>
</bean>
validationQuery - The SQL query that will be used to validate connections from this pool before returning them to the caller. If specified, this query MUST be an SQL SELECT statement that returns at least one row.
http://stackoverflow.com/questions/5636195/dbcp-and-hibernate-on-spring-doesnt-re-open-dead-connections-why