This is where the Tomcat application (persistence layer is hibernate) and the database are on different machines, and the connection breaks down when the database restarts or problems or the network is faulty. You will need to restart Tomcat after the repair, otherwise the application will continue to report connection refused errors. What is the way to get hibernate to automatically reconnect to the database after knowing that the connection failed?
Search on the Internet a lot of information is not a good solution, and finally replaced the connection pool, the use of Proxool
Specific configuration can see an article "Hibernate configuration Proxool" http://blog.csdn.net/cgboy88/archive/2010/05/10/5574839.aspx
One of the most important parameter settings is
Test-before-use: If True, the connection is serviced before each connection is tested, if one connection fails, it is discarded, another connection is processed, and if all connections fail, a new connection is established. Otherwise, a SqlException exception will be thrown.
Test-after-use: If True, the connection is serviced after each connection is tested and returned to the connection pool, which is discarded if the connection fails.
Test-before-use: and Test-after-use: I only chose one and tested the network to pass when disconnected.