jdbc-pool连接mysql自动断开

guanzhenxing 发布于 2014/04/25 14:15
阅读 401
收藏 0

大家好,

在用jdbc-pool连接mysql的时候总是会出现类似:


The last packet successfully received from the server was 11,246 milliseconds ago.  The last packet sent successfully to the server was 1 milliseconds ago.
以及



java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
的问题。在网上找了很久,但是还是没有找到合适的解决方法。


我的配置如下:

<bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource"
		destroy-method="close">
		<property name="poolProperties">
			<bean class="org.apache.tomcat.jdbc.pool.PoolProperties">
				<property name="driverClassName" value="${jdbc.driverClassName}" />
				<property name="url" value="${jdbc.url}" />
				<property name="username" value="${jdbc.username}" />
				<property name="password" value="${jdbc.password}" />
				<property name="testWhileIdle" value="true" />
				<property name="testOnBorrow" value="true" />
				<property name="testOnReturn" value="true" />
				<property name="validationQuery" value="SELECT 1" />	
				<property name="validationInterval" value="28800" />
				<property name="timeBetweenEvictionRunsMillis" value="3600000" />
				<property name="minEvictableIdleTimeMillis" value="120000" />
				<property name="removeAbandonedTimeout" value="6000000" />
				<property name="maxActive" value="100" />
				<property name="minIdle" value="10" />
				<property name="maxIdle" value="100"></property>
				<property name="maxWait" value="10000" />
				<property name="initialSize" value="30" />
				<property name="removeAbandoned" value="true" />
				<property name="logAbandoned" value="true" />
				<property name="jmxEnabled" value="true" />
				<property name="numTestsPerEvictionRun" value="50"></property>
				<property name="jdbcInterceptors"
					value="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer" />
			</bean>
		</property>

	</bean>



mysql中的参数如:

请问,我要怎么去配置呢?谢谢!

ps:不能更改数据库中的wait_timeout

加载中
0
vlaw
vlaw

<property name="timeBetweenEvictionRunsMillis" value="3600000" />

<property name="minEvictableIdleTimeMillis" value="120000" />


<property name="removeAbandonedTimeout" value="6000000" />
太大了

返回顶部
顶部