For months, my web application ran smoothly, but for the past week or two, it keeps dropping its connection to MySQL server. I\'m not a DBA guy and have no idea how to debug thi
It seems your connection pool cannot return a free connection to Hibernate within timeout duration. This happens because your application have very long transactions or transaction dead locks. You can try following options to fix the bug.
change your connection pool size in following line
make the pool size about 10 and test. You should keep your eye on the count of connections to your database. If it exceeds the mysql database connection limitations change max_connections
of mysql server and keep testing.
Use an another connection pool. I recommend to use apache commons dbcp2. Maven dependencies of dbcp2 as follows.
Add dbcp2 into your POM then config dbcp2 with your application.
If it was the solution your application had only long transactions. Sometimes it may minimize the occurrence, and if it is still happening definitely your application have transaction dead locks. So you have to identify what are the possible problems with your code.
There are other alternative solutions such changing the waiting timeout to a higher value. But it is not good for your application performance and it doesn't make any sense for transaction dead locks. Finally you should remember to care about transaction management and database structure in your further developments for better performance of database.