This is a discussion on Problem validating connections from connection pool within the MySQL Database forums, part of the Database Forums category; I'm using MySQL on a Tomcat server with the DBCP connection pool. I'm having trouble setting up the ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I'm using MySQL on a Tomcat server with the DBCP connection pool.
I'm having trouble setting up the connection pool such that it will validate connections. I initialized the connection pool object in an xml file like this - <bean id="my-datasource" class="org.apache.commons.dbcp.BasicDataSource" destroy- method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> <property name="initialSize" value="4"/> <property name="maxActive" value="400"/> <property name="maxIdle" value="40"/> <property name="poolPreparedStatements" value="true"/> <property name="validationQuery" value="select 1"/> <property name="testOnBorrow" value="true"/> </bean> To test it, I start Tomcat and run a few queries. Then I stop and restart my MySQL server, then I try to run the queries again. What I'm expecting to happen is that the connection pool will realize that the old connections don't work again and discard them before they're ever returned to my application. Instead, my application gets the bad connections and errors out trying to use them. This happens indefinitely until I restart Tomcat. I also tried using a query that actually queries a real table in my database, but that did not help. Is there something wrong with my configuration? This seems like a pretty simple and straightforward thing that should work with no fuss. Thanks, Frank |