Sha256: ffae87b1be42d8dae61ee12172d4a215281c6f005f1c7a8007edc238db448bfc

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

ArJdbc::ConnectionMethods.module_eval do
  def mysql_connection(config)
    begin
      require 'jdbc/mysql'
      ::Jdbc::MySQL.load_driver(:require) if defined?(::Jdbc::MySQL.load_driver)
    rescue LoadError # assuming driver.jar is on the class-path
    end

    config[:port] ||= 3306
    config[:url] ||= "jdbc:mysql://#{config[:host]}:#{config[:port]}/#{config[:database]}"
    config[:driver] ||= defined?(::Jdbc::MySQL.driver_name) ? ::Jdbc::MySQL.driver_name : 'com.mysql.jdbc.Driver'
    config[:adapter_class] = ActiveRecord::ConnectionAdapters::MysqlAdapter
    config[:adapter_spec] = ::ArJdbc::MySQL
    options = (config[:options] ||= {})
    options['zeroDateTimeBehavior'] ||= 'convertToNull'
    options['jdbcCompliantTruncation'] ||= 'false'
    options['useUnicode'] ||= 'true'
    options['characterEncoding'] = config[:encoding] || 'utf8'
    connection = jdbc_connection(config)
    ::ArJdbc::MySQL.kill_cancel_timer(connection.raw_connection)
    connection
  end
  alias_method :jdbcmysql_connection, :mysql_connection
  alias_method :mysql2_connection, :mysql_connection
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-jdbc-adapter-1.3.0.beta1 lib/arjdbc/mysql/connection_methods.rb