mysql重连,连接丢失:The last packet successfully received

- 如果是在Spring中使用DBCP连接池,在定义datasource增加属性validationQuerytestOnBorrow,如


 id="vrsRankDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
     name="driverClassName" value="${jdbc.driverClassName}" />
     name="url" value="${countNew.jdbc.url}" />
     name="username" value="${countNew.jdbc.user}" />
     name="password" value="${countNew.jdbc.pwd}" />
     name="validationQuery" value="SELECT 1" />
     name="testOnBorrow" value="true"/>

- 如果是在Spring中使用c3p0连接池,则在定义datasource的时候,添加属性testConnectionOnCheckintestConnectionOnCheckout,如


 name="cacheCloudDB" class="com.mchange.v2.c3p0.ComboPooledDataSource">
     name="driverClass" value="${jdbc.driver}"/>
     name="jdbcUrl" value="${cache.url}"/>
     name="user" value="${cache.user}"/>
     name="password" value="${cache.password}"/>
     name="initialPoolSize" value="10"/>
     name="maxPoolSize" value="${cache.maxPoolSize}"/>
     name="testConnectionOnCheckin" value="false"/>
     name="testConnectionOnCheckout" value="true"/>
     name="preferredTestQuery" value="SELECT 1"/>


你可能感兴趣的:(mysql)