Add compatibility with JRuby/JDBC and Rails 4