Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 3189

Show
Ignore:
Timestamp:
11/24/05 19:50:10 (3 years ago)
Author:
bitsweat
Message:

Oracle: active? check pings the database rather than testing the last command status. References #428.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r3188 r3189  
    11*SVN* 
     2 
     3* Oracle: active? check pings the database rather than testing the last command status.  #428 [Michael Schoen] 
    24 
    35* SQLServer: resolve column aliasing/quoting collision when using limit or offset in an eager find.  #2974 [kajism@yahoo.com] 
  • trunk/activerecord/lib/active_record/connection_adapters/oci_adapter.rb

    r3025 r3189  
    117117          time_array = ParseDate.parsedate value 
    118118          time_array[0] ||= 2000; time_array[1] ||= 1; time_array[2] ||= 1; 
    119           Time.send Base.default_timezone, *time_array 
     119          Time.send(Base.default_timezone, *time_array) rescue nil 
    120120        end 
    121121 
     
    216216        # Returns true if the connection is active. 
    217217        def active? 
    218           # Just checks the active flag, which is set false if the last exec 
    219           # got an error indicating a bad connection. An alternative would be 
    220           # to call #ping, which is more expensive (and should always get 
    221           # the same result). 
    222           @connection.active? 
     218          # Pings the connection to check if it's still good. Note that an 
     219          # #active? method is also available, but that simply returns the  
     220          # last known state, which isn't good enough if the connection has 
     221          # gone stale since the last use. 
     222          @connection.ping 
     223        rescue OCIError 
     224          false 
    223225        end 
    224226 
    225227        # Reconnects to the database. 
    226228        def reconnect! 
    227           begin 
    228             @connection.reset! 
    229           rescue OCIError => e 
    230             @logger.warn "#{adapter_name} automatic reconnection failed: #{e.message}" 
    231           end 
     229          @connection.reset! 
     230        rescue OCIError => e 
     231          @logger.warn "#{adapter_name} automatic reconnection failed: #{e.message}" 
    232232        end 
    233233 
     
    552552    # known state. 
    553553    def ping 
     554      @connection.commit 
    554555      @active = true 
    555       begin 
    556         @connection.commit 
    557       rescue 
    558         @active = false 
    559       end 
    560       active? 
     556    rescue 
     557      @active = false 
     558      raise 
    561559    end 
    562560