Sha256: 72f68ca126d2b85f42506f882bc38cdb871245af2cc0972ffba01ec5be418e04

Contents?: true

Size: 1.14 KB

Versions: 12

Compression:

Stored size: 1.14 KB

Contents

class ActiveRecord::Base
  class << self
    def mssql_connection(config)
      require "arjdbc/mssql"
      config[:host] ||= "localhost"
      config[:port] ||= 1433
      config[:driver] ||= "net.sourceforge.jtds.jdbc.Driver"
      config[:adapter_spec] = ::ArJdbc::MsSQL

      url = "jdbc:jtds:sqlserver://#{config[:host]}:#{config[:port]}/#{config[:database]}"

      # Instance is often a preferrable alternative to port when dynamic ports are used.
      # If instance is specified then port is essentially ignored.
      url << ";instance=#{config[:instance]}" if config[:instance]

      # This will enable windows domain-based authentication and will require the JTDS native libraries be available.
      url << ";domain=#{config[:domain]}" if config[:domain]

      # AppName is shown in sql server as additional information against the connection.
      url << ";appname=#{config[:appname]}" if config[:appname]
      config[:url] ||= url

      if !config[:domain]
        config[:username] ||= "sa"
        config[:password] ||= ""
      end
      jdbc_connection(config)
    end
    alias_method :jdbcmssql_connection, :mssql_connection
  end
end

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
cmoran92-activerecord-jdbc-adapter-1.2.1.2 lib/arjdbc/mssql/connection_methods.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.5 lib/arjdbc/mssql/connection_methods.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.4 lib/arjdbc/mssql/connection_methods.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.3 lib/arjdbc/mssql/connection_methods.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.2 lib/arjdbc/mssql/connection_methods.rb
activerecord-jdbc-adapter-1.2.2.1 lib/arjdbc/mssql/connection_methods.rb
activerecord-jdbc-adapter-onsite-1.2.2 lib/arjdbc/mssql/connection_methods.rb
cmoran92-activerecord-jdbc-adapter-1.2.1.1 lib/arjdbc/mssql/connection_methods.rb
activerecord-jdbc-adapter-1.2.2 lib/arjdbc/mssql/connection_methods.rb
cmoran92-activerecord-jdbc-adapter-1.2.1 lib/arjdbc/mssql/connection_methods.rb
activerecord-jdbc-adapter-1.2.1 lib/arjdbc/mssql/connection_methods.rb
activerecord-jdbc-adapter-1.2.0 lib/arjdbc/mssql/connection_methods.rb