I'm using JRuby 1.7.2, along with DataMapper, and I'm getting an error I can't find an answer to.

I'm just testing out DataMapper along with MySQL 5.5 to see if it will run fine when I build around it. Here's the file I'm testing:

require "data_mapper"
require "keys"

DataMapper.setup(:default, "mysql://#{$user}:#{$pass}@localhost/test_db")

And when I run this, I get the error:

NameError: cannot load Java class com.mysql.jdbc.Driver

And it points to the DataMapper.setup line.

My Gemfile should be alright:

source :rubygems

gem "sinatra"
gem "trinidad"
gem "data_mapper"

# do a `sudo apt-get install libmysqlclient-dev` first
gem "dm-mysql-adapter"
gem "jdbc-mysql"

Is there anything I'm missing? I have MySQL set up with a user/pass locally already.

share|improve this question

feedback

2 Answers

up vote 1 down vote accepted

This is a common error when running JDBC clients for MySQL. You need to make sure you have mysql-connector-java-bin.jar on the classpath. You can download it from here.

share|improve this answer
Worked like a charm. Thank you! – Imnotanerd Jan 10 at 19:33
feedback

actually, the correct answer is to work-around an incompatibility between 5.1.13 and 5.1.22 !

jdbc-mysql gem already contains the mysql-connector.jar it just ain't auto-loading anymore :

https://github.com/jruby/activerecord-jdbc-adapter/tree/master/jdbc-mysql (read the README)

share|improve this answer
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.