This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

[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)

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!