# File lib/rubyrep/session.rb, line 166
    def refresh_database_connection(database, options)
      if options[:forced] or database_unreachable?(database)
        # step 1: disconnect both database connection (if still possible)
        begin
          Thread.new do
            disconnect_database database rescue nil
          end.join configuration.options[:database_connection_timeout]
        end

        connect_exception = nil
        # step 2: try to reconnect the database
        Thread.new do
          begin
            connect_database database
          rescue Exception => e
            # save exception so it can be rethrown outside of the thread
            connect_exception = e
          end
        end.join configuration.options[:database_connection_timeout]
        raise connect_exception if connect_exception

        # step 3: verify if database connections actually work (to detect silent connection failures)
        if database_unreachable?(database)
          raise "no connection to '#{database}' database"
        end
      end
    end