Search code examples
jrubyjrubyonrails

Jruby On Rails, which is best database adapter, mysql2 or jdbcmysql?


I am working on JRuby on Rails Application having JRuby-1.6.7 and Rails 3.2.2

I have mysql database. I was trying for database adapter.

I used mysql2 and jdbcmysql database adapter. Both are working.

But if I do not access application for some time and after that when I access it, it gives error as follows

undefined method `explain' for #<ActiveRecord::ConnectionAdapters::MySQLAdapter:0x1139ba37>

Which database adapter I should prefer ? Will my aaplication work fine after deployment ?


Solution

  • I got the same error before, but after some effort I have defined adapter's in my gem file as below, and things are working fine till today :

    if defined?(JRUBY_VERSION)
      gem 'activerecord-jdbc-adapter', '=1.1.3'
      gem 'jdbc-mysql', :require=>false
      gem 'activerecord-jdbcmysql-adapter', '=1.1.3'
    else
      gem 'mysql2'
    end
    

    hope that helps .