ActiveRecord::AdapterNotFound:

I’m using active record in a script that I’m using to parse a text file
and load a mysql database.

It had been working fine for months but we hosed something up really
well. We gem installed Rails 3.2.9 (we’ll need to gem install 3.2.10 now
to fix the SQL injection vulnerability)

My script contains:

require ‘rubygems’
require ‘net/http’
require ‘yaml’
require ‘active_record’
require ‘logger’

#active record DB connection
dbconfig = YAML::load(File.open(‘database.yml’))
ActiveRecord::Base.establish_connection(dbconfig)

The database.yml contains:

adapter: jdbcmysql
encoding: utf8
reconnect: false
database: foo
pool: 5
username: bar
password: baz
host: localhost

When I run the script, it dies with:

F:\Websites\rsacfod-torque\lib\tasks>jruby -S 209pump.rb
ActiveRecord::AdapterNotFound: database configuration specifies
nonexistent jdbc mysql adapter
establish_connection at
f:/torquebox-2.0.3/jruby/lib/ruby/gems/1.8/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_specification.rb:133
(root) at 209pump.rb:9

All we did was bundle install the newest version of rails for a
completely different app. But I can see this is trying to use the newest
activerecord. Is there some issue with that?

You’ll need to require a couple of extra gems:

gem ‘activerecord-jdbc-adapter’
gem ‘activerecord-jdbcmysql-adapter’

gem ‘jdbc-mysql’ # I think you don’t need this if you have the

previous 2

  • Keith

Keith R. Bennett
http://about.me/keithrbennett

Keith B. wrote in post #1090949:

You’ll need to require a couple of extra gems:

gem ‘activerecord-jdbc-adapter’
gem ‘activerecord-jdbcmysql-adapter’

gem ‘jdbc-mysql’ # I think you don’t need this if you have the

previous 2

  • Keith

Keith R. Bennett
http://about.me/keithrbennett

If I’m not using a Gemfile (this is a standalone script that requires
activerecord) is this the same process? Most of my Ruby/JRuby work is in
the Rails context, but this script is not.

It looks like the problem occurs when using version 1.2.5 of
activerecord-jdbcmysql-adapter and activerecord-jdbc-adapter

I’ve backed the versions installed down to 1.2.2.1 and it’s working
again.

Sorry for giving you the wrong information, Jim. I am kind of curious
though how activerecord-jdbc-adapter knows to map the request for the
mysql adapter to the respective gem. I guess support for the most
common DB’s (mysql, sqlite, etc.) are built-in.

There is an issue that has been discussed on this list about
activerecord-jdbc-adapter. As I understand it, it will be fixed soon.

  • Keith

Keith R. Bennett
http://about.me/keithrbennett

Keith B. wrote in post #1090963:

Sorry for giving you the wrong information, Jim. I am kind of curious
though how activerecord-jdbc-adapter knows to map the request for the
mysql adapter to the respective gem. I guess support for the most
common DB’s (mysql, sqlite, etc.) are built-in.

There is an issue that has been discussed on this list about
activerecord-jdbc-adapter. As I understand it, it will be fixed soon.

  • Keith

Keith R. Bennett
http://about.me/keithrbennett

My best guess, is that when telling the database to use the jdbcmysql
adapter, (I am doing so in an external YAML file as I have several
scripts that use that connection info) activerecord simply uses the
newest gem available. 1.2.5 is the one that breaks compatibility. The
exception that it throws was what was tripping me up.

Thanks for the response regardless.

-Jim

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs