# Issue with Rails 2.2.2 + Jruby for mysql adapter

**URL:** <https://www.ruby-forum.com/t/issue-with-rails-2-2-2-jruby-for-mysql-adapter/154264>\
**Category:** JRuby\
**Created:** [November 27, 2008, 1:10am UTC](https://www.ruby-forum.com/t/issue-with-rails-2-2-2-jruby-for-mysql-adapter/154264 "2008-11-27T01:10:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vivek\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e0b2c6/32.png) [@Vivek\_P](https://www.ruby-forum.com/u/Vivek_P)\
**Post date:** [November 27, 2008, 1:10am UTC](https://www.ruby-forum.com/t/issue-with-rails-2-2-2-jruby-for-mysql-adapter/154264/1 "2008-11-27T01:10:10Z")

</div>

I am trying to create a simple Rails 2.2.2 app using jruby 1.1.5. The  
application is using mysql DB. The gems installed are:  
$jruby -S gem list

\*\*\* LOCAL GEMS \*\*\*

actionmailer (2.2.2)  
actionpack (2.2.2)  
activerecord (2.2.2)  
activeresource (2.2.2)  
activesupport (2.2.2)  
glassfish (0.9.0)  
jdbc-mysql (5.0.4)  
rack (0.4.0)  
rails (2.2.2)  
rake (0.8.3)  
rspec (1.1.11)  
sources (0.0.1)  
[/c/dev/rails/book]

## During migration I get this error from Rails that 2.2.2 no longer ships mysql.rb:

## $jruby -S rake db:create (in C:/dev/rails/book) !!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install t he mysql gem and try again: gem install mysql. rake aborted! no such file to load – mysql

When I try to do: jruby -S gem install mysql, it can’t install as jruby  
does  
not support native extension. So the only option I have is to  
install activerecord-jdbcmysql-adapter or someone got any better way to  
go  
past these errors?

* * *

## $jruby -S gem install mysql JRuby limited openssl loaded. gem install jruby-openssl for full support. [http://wiki.jruby.org/wiki/JRuby\_Builtin\_OpenSSL](http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL) Building native extensions. This could take a while… C:/tools/jruby/lib/ruby/1.8/mkmf.rb:7: JRuby does not support native extensions. Check [wiki.jruby.org](http://wiki.jruby.org) for alternatives. (NotImplementedError) from C:/tools/jruby/lib/ruby/1.8/mkmf.rb:1:in `require’ from extconf.rb:1 ERROR: Error installing mysql: ERROR: Failed to build gem native extension.

-vivek.

---

<div class="post-metadata">

**Author:** ![Vivek\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e0b2c6/32.png) [@Vivek\_P](https://www.ruby-forum.com/u/Vivek_P)\
**Post date:** [November 27, 2008, 2:20am UTC](https://www.ruby-forum.com/t/issue-with-rails-2-2-2-jruby-for-mysql-adapter/154264/2 "2008-11-27T02:20:19Z")

</div>

Hi Vivek -

As I understand it (and I’m no expert), what you’ve done is the  
correct way to fix that. I also have a Rails 2.2.2 app that I run with  
JRuby 1.1.5, and I have these gems installed to support it:

activerecord-jdbcmysql-adapter (0.8.2)  
jdbc-mysql (5.0.4)

In my database.yml file, the adapter is configured like this:

development:  
host: localhost  
adapter: jdbcmysql  
database: tt\_dev  
port: 3306  
username: root  
password:

Hope that’s helpful (or at least not wrong). 🙂

---

<div class="post-metadata">

**Author:** ![Vivek\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e0b2c6/32.png) [@Vivek\_P](https://www.ruby-forum.com/u/Vivek_P)\
**Post date:** [November 27, 2008, 11:30am UTC](https://www.ruby-forum.com/t/issue-with-rails-2-2-2-jruby-for-mysql-adapter/154264/3 "2008-11-27T11:30:38Z")

</div>

Vivek P. wrote:

> activerecord (2.2.2)
> 
> ## rake aborted! no such file to load – mysql
> 
> When I try to do: jruby -S gem install mysql, it can’t install as  
> jruby does not support native extension. So the only option I have is  
> to install activerecord-jdbcmysql-adapter or someone got any better  
> way to go past these errors?

I think another option is to copy the Ruby MySql driver to /lib. You can download it from [Ruby/MySQL](http://www.tmtm.org/en/ruby/mysql/),  
or just copy it from an older version of activerecord (e.g.  
gems/activerecord-2.1.2/lib/active\_record/vendor/mysql.rb). Probably  
better to use the jdbc adapter anyway, just wanted to point out this  
option too.

Erno

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```

---

<div class="post-metadata">

**Author:** ![Vivek\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e0b2c6/32.png) [@Vivek\_P](https://www.ruby-forum.com/u/Vivek_P)\
**Post date:** [November 27, 2008, 7:09am UTC](https://www.ruby-forum.com/t/issue-with-rails-2-2-2-jruby-for-mysql-adapter/154264/4 "2008-11-27T07:09:43Z")

</div>

Hi Vivek

Seems like you’re missing the jdbc adapter

gem install activerecord-jdbcmysql-adapter  
and change the adapters entry in database.yml to: adapter: jdbcmysql

/Mikael

Vivek P. wrote:

> activerecord (2.2.2)
> 
> ## rake aborted! JRuby limited openssl loaded. gem install jruby-openssl for full support.
> 
> -vivek.

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email
```

---

<div class="post-metadata">

**Author:** ![Vivek\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e0b2c6/32.png) [@Vivek\_P](https://www.ruby-forum.com/u/Vivek_P)\
**Post date:** [December 1, 2008, 1:24pm UTC](https://www.ruby-forum.com/t/issue-with-rails-2-2-2-jruby-for-mysql-adapter/154264/5 "2008-12-01T13:24:56Z")

</div>

Erno M. wrote:

> I think another option is to copy the Ruby MySql driver to /lib. You can download it from [Ruby/MySQL](http://www.tmtm.org/en/ruby/mysql/),  
> or just copy it from an older version of activerecord (e.g.  
> gems/activerecord-2.1.2/lib/active\_record/vendor/mysql.rb). Probably  
> better to use the jdbc adapter anyway, just wanted to point out this  
> option too.

Which raises another question; other than age/support, what IS the  
reason for  
not using the old mysql adapter? Is the JDBC one better in any way?

–  
Twitter: [http://twitter.com/campbellmichael](http://twitter.com/campbellmichael)

* * *

To unsubscribe from this list, please visit:

```
http://xircles.codehaus.org/manage_email

```

---

<div class="post-metadata">

**Author:** ![Vivek\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e0b2c6/32.png) [@Vivek\_P](https://www.ruby-forum.com/u/Vivek_P)\
**Post date:** [December 2, 2008, 3:55am UTC](https://www.ruby-forum.com/t/issue-with-rails-2-2-2-jruby-for-mysql-adapter/154264/6 "2008-12-02T03:55:58Z")

</div>

Wel, the mysql adapter works fine on JVM on windows platform. Although  
for  
some reason it does not work on ubuntu.

-vivek.

---

<div class="post-metadata">

**Author:** ![Vivek\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e0b2c6/32.png) [@Vivek\_P](https://www.ruby-forum.com/u/Vivek_P)\
**Post date:** [December 1, 2008, 3:12pm UTC](https://www.ruby-forum.com/t/issue-with-rails-2-2-2-jruby-for-mysql-adapter/154264/7 "2008-12-01T15:12:56Z")

</div>

Yeah. The MySql adapter has native code that does not run in the JVM.  
And  
the pure Ruby variant does not work on 4.1 or 5.x.

On Mon, Dec 1, 2008 at 7:24 AM, Michael C. \<

---

<div class="post-metadata">

**Author:** ![Vivek\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e0b2c6/32.png) [@Vivek\_P](https://www.ruby-forum.com/u/Vivek_P)\
**Post date:** [December 2, 2008, 4:13am UTC](https://www.ruby-forum.com/t/issue-with-rails-2-2-2-jruby-for-mysql-adapter/154264/8 "2008-12-02T04:13:31Z")

</div>

If you got an error on Ubuntu like this:

/home/ryan/opt/jruby-1.1.5/lib/ruby/1.8/mkmf.rb:7: JRuby does not  
support  
native extensions. Check [wiki.jruby.org](http://wiki.jruby.org) for alternatives.  
(NotImplementedError)  
from /home/ryan/opt/jruby-1.1.5/lib/ruby/1.8/mkmf.rb:1:in `require’  
from extconf.rb:1  
ERROR: Error installing mysql:  
ERROR: Failed to build gem native extension.

It’s because JRuby doesn’t run the native extensions. Your only real  
choice  
in that case it to install the jdbc variant.
