Ticket #428: oci_ping.patch
| File oci_ping.patch, 2.2 kB (added by mschoen, 3 years ago) |
|---|
-
activerecord/lib/active_record/connection_adapters/oci_adapter.rb
old new 116 116 return value if value.is_a? Time 117 117 time_array = ParseDate.parsedate value 118 118 time_array[0] ||= 2000; time_array[1] ||= 1; time_array[2] ||= 1; 119 Time.send Base.default_timezone, *time_array119 Time.send(Base.default_timezone, *time_array) rescue nil 120 120 end 121 121 122 122 def guess_date_or_time(value) … … 215 215 216 216 # Returns true if the connection is active. 217 217 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 223 225 end 224 226 225 227 # Reconnects to the database. 226 228 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}" 232 232 end 233 233 234 234 … … 551 551 # checks the connection, while #active? simply returns the last 552 552 # known state. 553 553 def ping 554 @connection.commit 554 555 @active = true 555 begin 556 @connection.commit 557 rescue 558 @active = false 559 end 560 active? 556 rescue 557 @active = false 558 raise 561 559 end 562 560 563 561 # Resets connection, by logging off and creating a new connection.