Sha256: 4d9fcd24080c27a92b7ab68c65121ed72476534534d1454156ed894e239ccfb9
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 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[:username] = 'root' unless config.key?(:username) # jdbc:mysql://[host][,failoverhost...][:port]/[database] # - if the host name is not specified, it defaults to 127.0.0.1 # - if the port is not specified, it defaults to 3306 # - alternate fail-over syntax: [host:port],[host:port]/[database] unless config[:url] host = config[:host]; host = host.join(',') if host.respond_to?(:join) url = "jdbc:mysql://#{host}" url << ":#{config[:port]}" if config[:port] url << "/#{config[:database]}" config[:url] = url end config[:driver] ||= defined?(::Jdbc::MySQL.driver_name) ? ::Jdbc::MySQL.driver_name : 'com.mysql.jdbc.Driver' config[:adapter_spec] ||= ::ArJdbc::MySQL config[:adapter_class] = ActiveRecord::ConnectionAdapters::MysqlAdapter unless config.key?(:adapter_class) properties = ( config[:properties] ||= {} ) properties['zeroDateTimeBehavior'] ||= 'convertToNull' properties['jdbcCompliantTruncation'] ||= 'false' properties['useUnicode'] ||= 'true' properties['characterEncoding'] = config[:encoding] || 'utf8' jdbc_connection(config) 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.2 | lib/arjdbc/mysql/connection_methods.rb |