提交 c98011bc 编写于 作者: J Jeremy Kemper

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
上级 e7b65b59
*SVN*
* SQLServer: active? and reconnect! methods for handling stale connections. #428 [kajism@yahoo.com]
* SQLServer: active? and reconnect! methods for handling stale connections. #428 [kajism@yahoo.com, Tom Ward <tom@popdog.net>]
* Associations handle case-equality more consistently: item.parts.is_a?(Array) and item.parts === Array. #1345 [MarkusQ@reality.com]
......
......@@ -207,24 +207,21 @@ def supports_migrations? #:nodoc:
# 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册