public void reduceDatabaseConnection ( ) { synchronized ( LOCK ) { int numberOfOpenConnections = OPEN_CONNECTIONS . decrementAndGet ( ) ; if ( numberOfOpenConnections == 0 && dbConnection != null ) { dbConnection . close ( ) ; dbConnection = null ; } } }
Reduce the connection opened . This should always be called after calling getDatabaseConnection and only after that .