1 # Don't need to load native mysql adapter
2 $LOADED_FEATURES << "active_record/connection_adapters/mysql_adapter.rb"
3 $LOADED_FEATURES << "active_record/connection_adapters/mysql2_adapter.rb"
5 class ActiveRecord::Base
7 def mysql_connection(config)
10 options = (config[:options] ||= {})
11 options['zeroDateTimeBehavior'] ||= 'convertToNull'
12 options['jdbcCompliantTruncation'] ||= 'false'
13 options['useUnicode'] ||= 'true'
14 options['characterEncoding'] = config[:encoding] || 'utf8'
15 config[:url] ||= "jdbc:mysql://#{config[:host]}:#{config[:port]}/#{config[:database]}"
16 config[:driver] ||= "com.mysql.jdbc.Driver"
17 config[:adapter_class] = ActiveRecord::ConnectionAdapters::MysqlAdapter
18 connection = jdbc_connection(config)
19 ::ArJdbc::MySQL.kill_cancel_timer(connection.raw_connection)
22 alias_method :jdbcmysql_connection, :mysql_connection
23 alias_method :mysql2_connection, :mysql_connection