我有一臺機器運行一個java應用程序,與在同一實例上運行的mysql實例進行通話。應用程序 使用來自mysql的jdbc4驅動程序。我隨機獲取com.mysql.jdbc.exceptions.jdbc4.CommunicationsException 。jdbc4 CommunicationsException
這是整個消息。
無法爲事務打開JDBC連接;嵌套的異常是
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was25899 milliseconds ago.The last packet sent successfully to the server was 25899 milliseconds ago, which is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
對於MySQL,全球「WAIT_TIMEOUT」和「interactive_timeout」的值被設置爲3600秒和「connect_timeout」被設定爲60秒。等待超時值遠高於26秒(25899毫秒)。在異常追蹤中提到。
我使用dbcp進行連接池,這裏是數據源的spring bean配置。
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource" >
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/db"/>
<property name="username" value="xxx"/>
<property name="password" value="xxx" />
<property name="poolPreparedStatements" value="false" />
<property name="maxActive" value="3" />
<property name="maxIdle" value="3" />
</bean>
任何想法爲什麼會發生這種情況?請問用c3p0解決問題?
Thnx,這似乎目前正在工作。 – letronje 2009-08-14 10:07:58