Tôi có một máy chạy một ứng dụng java nói chuyện với một cá thể mysql chạy trên cùng một cá thể. ứng dụng sử dụng trình điều khiển jdbc4 từ mysql. Tôi tiếp tục nhận được com.mysql.jdbc.exceptions.jdbc4.CommunicationsException vào các thời điểm ngẫu nhiên.jdbc4 CommunicationsException
Đây là toàn bộ thư.
Không thể mở kết nối JDBC để giao dịch; lồng nhau ngoại lệ là
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.
Đối với mysql, giá trị của toàn cầu 'wait_timeout' và 'interactive_timeout' được đặt thành 3600 giây và 'connect_timeout' được đặt thành 60 giây. giá trị thời gian chờ chờ cao hơn nhiều so với 26 giây (25899 ms giây). được đề cập trong dấu vết ngoại lệ.
Tôi sử dụng dbcp để kết nối tổng hợp và đây là cấu hình bean mùa xuân cho nguồn dữ liệu.
<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>
Bất kỳ ý tưởng nào tại sao điều này có thể xảy ra? Sẽ sử dụng c3p0 giải quyết vấn đề?
Thnx, điều này dường như đang hoạt động tại thời điểm này. – letronje