diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-15 15:58:36 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-15 15:58:36 +0000 |
commit | c98011bc32ac892f38bbda15b485c87a35795bba (patch) | |
tree | d233cb5059f04fb1922193ca9bd54b178dff17d0 /activerecord/lib | |
parent | e7b65b590a386537fa17898aaba47d816c1ea215 (diff) | |
download | rails-c98011bc32ac892f38bbda15b485c87a35795bba.tar.gz rails-c98011bc32ac892f38bbda15b485c87a35795bba.tar.bz2 rails-c98011bc32ac892f38bbda15b485c87a35795bba.zip |
SQLServer: active? and reconnect! methods for handling stale connections. References #428.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3045 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb index 78486a2a1a..9320717b34 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb @@ -207,24 +207,21 @@ module ActiveRecord # Returns true if the connection is active. def active? - @connection.execute("SELECT 1") {|sth|} + @connection.execute("SELECT 1") { } true - rescue DBI::DatabaseError => e + rescue DBI::DatabaseError, DBI::InterfaceError false end - # Reconnects to the database. + # Reconnects to the database, returns false if no connection could be made. def reconnect! - begin - @connection.disconnect - @connection = DBI.connect(*@connection_options) - rescue DBI::DatabaseError => e - @logger.warn "#{adapter_name} automatic reconnection failed: #{e.message}" - end + @connection.disconnect rescue nil + @connection = DBI.connect(*@connection_options) + rescue DBI::DatabaseError => e + @logger.warn "#{adapter_name} reconnection failed: #{e.message}" if @logger + false end - - def select_all(sql, name = nil) select(sql, name) end |