It seems that you found the reason: you have problems with DNS, so attempts to search your database by name freeze, and connecting to your database by IP address is fine. The c3p0 messages you see indicate that attempts to get connections from the database hang (that is, they do not succeed and fail with the exception). In the end, those who hung the tasak exhaust c3p0 thread pool, and you see APPARENT DEADLOCK warnings.
The setting suggested by user1516873, statementCacheNumDeferredCloseThreads, is useful when you see statement-related tasks that cause deadlocks, but are unlikely to help in your case. You are trying to connect pools to database connections.
The main thing you need to do is debug the DNS problem on your web application server. Try tools like nslookup or dig and see if you can search the database server by name and if the results come immediately or if you freeze in the search. From what you described, you are likely to find a problem there.
Steve waldman
source share