Exception: socket write error

These days, this exception always occur in my new developing application using persistence, especially on the morning when I came back to office. At the beginning, I think it may be due to the use of Java Persistence. However, when I do a search on Google, at the top of the list, I got this post:

http://www.yannicafe.info/wp/2006/11/25/53.html

This post describes the case in detail. It is due to the mechanism of MySQL, where this DB will disconnect all the active connections after 8 hours if there is no activity. After that, if your application try to work on some activities, the above exception is caused.

Normally, the exception should be caught in the application, and direct to a reconnect logic. However, the persistence provider (Oracle TopLink) that I am using does not provide auto reconnect function. So, I need to change the connection URL to the following:

jdbc:mysql://localhost:3306/test?autoReconnect=true

This allow the application to auto reconnect in case MySQL disconnects all the connections. Nevertheless, the bad thing is that  this is not recommended by MySQL community and this parameter may even be removed from future versions of MySQL.

Reference:
http://forums.java.net/jive/thread.jspa?messageID=189962

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • Technorati
  • YahooMyWeb

 

February 2007
S M T W T F S
« Jan   Mar »
 123
45678910
11121314151617
18192021222324
25262728  

Categories