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

Changeset 3205

Show
Ignore:
Timestamp:
12/02/05 01:19:18 (3 years ago)
Author:
bitsweat
Message:

Firebird: active? and reconnect! methods for handling stale connections. References #428.

Files:

Legend:

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

    r3202 r3205  
    11*SVN* 
     2 
     3* Firebird: active? and reconnect! methods for handling stale connections.  #428 [Ken Kunz <kennethkunz@gmail.com>] 
    24 
    35* Firebird: updated for FireRuby 0.4.0.  #3009 [Ken Kunz <kennethkunz@gmail.com>] 
  • trunk/activerecord/lib/active_record/connection_adapters/firebird_adapter.rb

    r3202 r3205  
    3232      end 
    3333      options = config[:charset] ? { CHARACTER_SET => config[:charset] } : {} 
     34      connection_params = [config[:username], config[:password], options] 
    3435      db = FireRuby::Database.new_from_params(*config.values_at(:database, :host, :port, :service)) 
    35       connection = db.connect(config[:username], config[:password], options) 
    36       ConnectionAdapters::FirebirdAdapter.new(connection, logger
     36      connection = db.connect(*connection_params) 
     37      ConnectionAdapters::FirebirdAdapter.new(connection, logger, connection_params
    3738    end 
    3839  end 
     
    241242      cattr_accessor :boolean_domain 
    242243 
     244      def initialize(connection, logger, connection_params=nil) 
     245        super(connection, logger) 
     246        @connection_params = connection_params 
     247      end 
     248 
    243249      def adapter_name # :nodoc: 
    244250        'Firebird' 
     
    254260        "#{table_name}_seq" 
    255261      end 
     262 
    256263 
    257264      # QUOTING ================================================== 
     
    280287        quote(boolean_domain[:false]) 
    281288      end 
     289 
     290 
     291      # CONNECTION MANAGEMENT ==================================== 
     292 
     293      def active? 
     294        not @connection.closed? 
     295      end 
     296 
     297      def reconnect! 
     298        @connection.close 
     299        @connection = @connection.database.connect(*@connection_params) 
     300      end 
     301 
    282302 
    283303      # DATABASE STATEMENTS ====================================== 
     
    340360        FireRuby::Generator.new(sequence_name, @connection).next(1) 
    341361      end 
     362 
    342363 
    343364      # SCHEMA STATEMENTS ========================================