I have a
java thread, it will update the database every 15 minutes, only when the thread got started, it creates a connection pool to the database. But our database will be shut down during the weekend, after this, the connection pool contains unuseful connections. I have to restart the thread to recreate the connection pool. Does anybody got experience to handle this issue without restarting the thread?
I thought we could use catch block to catch exception, assuming I have 5 connections in the pool, so after I got 5 exceptions(each get connection method will throw one exception), I set up a static variable BAD_CONNECTION to true, then when next time, my thread runs, it will check the variable BAD_CONNECTION, if it's true, a new connection pool will be created. But what happens to the old connection pool? it will be automatically garbage collected? Say if database down for a long time, my thread will create a bunch of unuseful connection pools, since it runs every 15 minutes. Is there any memory leak here?
Any comments would be welcome.