my dog learned polymorphism*
The moose likes JDBC and the fly likes [MySQL] Connection reset by peer: socket write error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "[MySQL] Connection reset by peer: socket write error" Watch "[MySQL] Connection reset by peer: socket write error" New topic
Author

[MySQL] Connection reset by peer: socket write error

Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
From Tomcat Error Stacktrace :

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was51906 milliseconds ago.The last packet sent successfully to the server was 51906 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.

Increasing the timeout doesn't sound good solution. The other solution is to use the property 'autoReconnect=true',which I have already applied.

From Apache Tomcat 6.0,context.xml (I guess it's called JNDI?) :

How can I get rid of this exception? This sounds like general issue.
PS : I am using hibernate3. Is there any such property to configure into hibernate config file or the solution lies into JDBC connection string or MySQL server side?
Ram Para
Ranch Hand

Joined: Jul 09, 2008
Posts: 50
autoReconnect=true is now deprecated and not a good practice to use.

Try using connection pooling using ajp3 in hibernate.

Ram Parashar
http://doinfinite.com
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
What is ajp3? I googled it but no information.
Ram Para
Ranch Hand

Joined: Jul 09, 2008
Posts: 50
I am Sorry.

Its C3P0.

You can check the following URL.

https://www.hibernate.org/214.html
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Ok I have added below line in hibernate config file.

from that link oit says 0 means never expires and that's what I want.
Let's see.
Ram Para
Ranch Hand

Joined: Jul 09, 2008
Posts: 50
for using this property you have to add c3p0-0.9.1.jar to lib.

you can use other properties also.

<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>

You can change the values.

Maintaining a Connection pool will help you to avoid the time taken in new Connections.

Timeout 0 is not a good practice as it can result in infinite loops.(Deadlocks)

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [MySQL] Connection reset by peer: socket write error
 
Similar Threads
Problem at connection
ERROR org.hibernate.util.JDBC Exception Reporter
spring / ibatis issue
Tomcat serving Blank Page - shows on Refresh - why?
Communication EXCEPTION