| 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: 48
|
|
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: 48
|
|
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: 48
|
|
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)
|
 |
 |
|
|
subject: [MySQL] Connection reset by peer: socket write error
|
|
|