def mysql_connection(config)
require File.dirname(__FILE__) + "/../active_record/connection_adapters/mysql_adapter"
config[:port] ||= 3306
url_options = "zeroDateTimeBehavior=convertToNull&jdbcCompliantTruncation=false&useUnicode=true&characterEncoding="
url_options << (config[:encoding] || 'utf8')
if config[:url]
config[:url] = config[:url]['?'] ? "#{config[:url]}&#{url_options}" : "#{config[:url]}?#{url_options}"
else
config[:url] = "jdbc:mysql://#{config[:host]}:#{config[:port]}/#{config[:database]}?#{url_options}"
end
config[:driver] = "com.mysql.jdbc.Driver"
connection = jdbc_connection(config)
::JdbcSpec::MySQL.kill_cancel_timer(connection.raw_connection)
connection
end