Win a copy of Microservices in Action this week in the Web Services forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

[MySQL] Connection reset by peer: socket write error  RSS feed

 
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
autoReconnect=true is now deprecated and not a good practice to use.

Try using connection pooling using ajp3 in hibernate.
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is ajp3? I googled it but no information.
 
Ram Para
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am Sorry.

Its C3P0.

You can check the following URL.

https://www.hibernate.org/214.html
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!