-1

I am working with a Java Web application(spring mvc) connecting to a Mysql database . When i left my application overnight and there is no request to process during the night, in the morning it was throwing java.sql.SQLException: Communication link failure: java.net.SocketException, underlying cause: Software caused connection abort: recv failed error. i am using Apache JDBC connection pool i.e. in my Spring config file.

I did some research and found that the real cause of the problem was that database timed out the connection when left idle and when Java application tries to connect to the database using those stale connection it throws

java.sql.SQLException: Communication link failure:
java.net.SocketException, underlying cause: Software caused connection abort: recv failed error.
  • You may try implementing a sort of heartbeat mechanism that would make a simple request to the DB, say, every minute to keep the connection alive. For instance, implement a simple stored function that receives an integer value and returns the same value. This will consume nearly nothing from your server's resources while preventing idle timeout. – FDavidov Dec 06 '16 at 08:55
  • 3
    Exact duplicate of [Official reasons for "Software caused connection abort: socket write error"](http://stackoverflow.com/questions/2126607/official-reasons-for-software-caused-connection-abort-socket-write-error) – user207421 Dec 06 '16 at 08:58
  • Your 'lot of research' should not have turned up anything of the sort. – user207421 Dec 06 '16 at 09:21

1 Answers1

0

i fixed this probleme by increasing the timeout value in mysql config file = C:\Program Files (x86)\MySQL\MySQL Server 5.1\my.ini :

[mysqld] wait_timeout=2147483 interactive_timeout=2147483

and then i have restarted mysql service.

thank you @EJP