Sha256: 4fdf57c27c156c7d4175b0eae5d24f2f3a2b0db6ca1a23415b3d9e4761d421b4

Contents?: true

Size: 968 Bytes

Versions: 3

Compression:

Stored size: 968 Bytes

Contents

module ArJdbc
  if ActiveRecord.const_defined? :ConnectionHandling # 4.0
    ConnectionMethods = ActiveRecord::ConnectionHandling
  else # 3.x
    ConnectionMethods = (class << ActiveRecord::Base; self; end)
  end
  ConnectionMethods.module_eval do

    def jdbc_connection(config)
      adapter_class = config[:adapter_class]
      adapter_class ||= ::ActiveRecord::ConnectionAdapters::JdbcAdapter

      # Once all adapters converted to AR5 then this rescue can be removed
      begin
        adapter_class.new(nil, logger, nil, config)
      rescue ArgumentError
        adapter_class.new(nil, logger, config)
      end
    end

    def jndi_connection(config); jdbc_connection(config) end

    def embedded_driver(config)
      config[:username] ||= "sa"
      config[:password] ||= ""
      jdbc_connection(config)
    end

    private

    def jndi_config?(config)
      ::ActiveRecord::ConnectionAdapters::JdbcConnection.jndi_config?(config)
    end

  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
activerecord-jdbc-adapter-51.0 lib/arjdbc/jdbc/connection_methods.rb
neo-activerecord-jdbc-adapter-5.0.pre2 lib/arjdbc/jdbc/connection_methods.rb
activerecord-jdbc-adapter-5.0.pre1 lib/arjdbc/jdbc/connection_methods.rb