I have an application that I use BoneCP for connection pooling and when I deploy the war to tomcat, it works perfectly. But when I create another war (almost identical, just different skin and DB connection) ans deploy them both the I get the following error when tomcat starts up:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections"
Note that this does not happen after a period of time, so it is not that I am leaking connections by not closing them, but rather on startup.
My hibernate/boneCP connection properties in my spring config are as follows:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="hibernateProperties">
<props>
<prop key="hibernate.connection.provider_class">com.jolbox.bonecp.provider.BoneCPConnectionProvider</prop>
<prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
<prop key="hibernate.connection.url">${connection.url}</prop>
<prop key="hibernate.connection.username">${connection.username}</prop>
<prop key="hibernate.connection.password">${connection.password}</prop>
<prop key="bonecp.idleMaxAge">60</prop>
<prop key="bonecp.idleConnectionTestPeriod">5</prop>
<prop key="bonecp.partitionCount">3</prop>
<prop key="bonecp.acquireIncrement">10</prop>
<prop key="bonecp.maxConnectionsPerPartition">60</prop>
<prop key="bonecp.minConnectionsPerPartition">20</prop>
<prop key="bonecp.statementsCacheSize">50</prop>
<prop key="bonecp.releaseHelperThreads">3</prop>
</props>
</property>
....
Anyone got any ideas?