# How do I use Ruby on Rails 3.1 with DataMapper on JRuby with a DB2/400 database?

**URL:** <https://www.ruby-forum.com/t/how-do-i-use-ruby-on-rails-3-1-with-datamapper-on-jruby-with-a-db2-400-database/210792>\
**Category:** JRuby\
**Created:** [August 17, 2011, 5:07pm UTC](https://www.ruby-forum.com/t/how-do-i-use-ruby-on-rails-3-1-with-datamapper-on-jruby-with-a-db2-400-database/210792 "2011-08-17T17:07:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [August 17, 2011, 5:07pm UTC](https://www.ruby-forum.com/t/how-do-i-use-ruby-on-rails-3-1-with-datamapper-on-jruby-with-a-db2-400-database/210792/1 "2011-08-17T17:07:56Z")

</div>

Hi, all!

[Note: this is a repost of [How do I use Ruby on Rails 3.1 with DataMapper on JRuby with a DB2/400 database? - Stack Overflow](http://StackOverflow.Com/q/7094661/) . Feel  
free to answer over there, if you like.]

I am developing a Rails 3.1 application on top of a legacy DB2/400  
database. Because of the better support for legacy schemas, I opted to  
use DataMapper instead of ActiveRecord as the ORM. The application is  
going to be deployed on JRuby.

What is the best way to access a DB2 database in this case?

My initial research indicated that this would be trivial, since one of  
the major selling points of using JRuby on Rails is that you get JDBC,  
and thus access to pretty much any database on the planet.

However, it appears that is not necessarily true, in particular, there  
doesn’t seem to be any driver for either ActiveRecord or  
DataMapper/DataObjects for using DB2 over JDBC.

Do I have to write my own driver? From reading the source code of the  
various existing DataObjects/DataMapper JDBC drivers, this shouldn’t  
be too hard, but it is something I’d rather like to avoid.

Is there any ready-made solution (library, gem, blog post, tutorial)  
for using DB2/400 with JRuby on Rails with DataMapper? If not, how do  
I do it?

Thanks in advance,  
jwm

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 17, 2011, 8:51pm UTC](https://www.ruby-forum.com/t/how-do-i-use-ruby-on-rails-3-1-with-datamapper-on-jruby-with-a-db2-400-database/210792/2 "2011-08-17T20:51:47Z")

</div>

Hi,

I have used activerecord-jdbc-adapter against an AS400 (db2 variant)  
with no problems. Check out

> **[activerecord-jdbc-adapter/lib/arjdbc/db2 at master ·...](https://github.com/nicksieger/activerecord-jdbc-adapter/tree/master/lib/arjdbc/db2)**
>
> master/lib/arjdbc/db2

for a start. I used this in Rails 2.3.X apps and a Rails 3.0.X app.

Also, I have used sequel do it  
[https://github.com/jeremyevans/sequel/blob/master/lib/sequel/adapters/jdbc/as400.rb](https://github.com/jeremyevans/sequel/blob/master/lib/sequel/adapters/jdbc/as400.rb)  
in a Rails 3.X app. You will need something like this too

> **[GitHub - bhauff/sequel-rails: A gem for using Sequel with Rails3](https://github.com/bhauff/sequel-rails)**
>
> A gem for using Sequel with Rails3. Contribute to bhauff/sequel-rails development by creating an account on GitHub.

In either of these cases some things are broken or missing like  
migrations in arjdbc. I did have sequel migrations working with some  
hacking.

I was never able to get it running with datamapper.

Thanks,

Brandon

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 18, 2011, 11:47am UTC](https://www.ruby-forum.com/t/how-do-i-use-ruby-on-rails-3-1-with-datamapper-on-jruby-with-a-db2-400-database/210792/3 "2011-08-18T11:47:45Z")

</div>

Brandon H. wrote:

> In either of these cases some things are broken or missing like  
> migrations in arjdbc. I did have sequel migrations working with  
> some hacking.

Thanks, that’s very helpful. The DB is “owned” by Synon models, so  
migrations aren’t something I need to worry about anyway.

> I was never able to get it running with datamapper.

jwm

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 24, 2011, 10:29pm UTC](https://www.ruby-forum.com/t/how-do-i-use-ruby-on-rails-3-1-with-datamapper-on-jruby-with-a-db2-400-database/210792/4 "2011-08-24T22:29:48Z")

</div>

Brandon H. wrote in post #1017155:

> Hi,
> 
> I have used activerecord-jdbc-adapter against an AS400 (db2 variant)  
> with no problems. Check out

> **[activerecord-jdbc-adapter/lib/arjdbc/db2 at master ·...](https://github.com/nicksieger/activerecord-jdbc-adapter/tree/master/lib/arjdbc/db2)**
>
> master/lib/arjdbc/db2

> for a start. I used this in Rails 2.3.X apps and a Rails 3.0.X app.
> 
> Also, I have used sequel do it

[https://github.com/jeremyevans/sequel/blob/master/lib/sequel/adapters/jdbc/as400.rb](https://github.com/jeremyevans/sequel/blob/master/lib/sequel/adapters/jdbc/as400.rb)

> in a Rails 3.X app. You will need something like this too  
> [GitHub - bhauff/sequel-rails: A gem for using Sequel with Rails3 · GitHub](https://github.com/bhauff/sequel-rails)
> 
> In either of these cases some things are broken or missing like  
> migrations in arjdbc. I did have sequel migrations working with some  
> hacking.
> 
> I was never able to get it running with datamapper.
> 
> Thanks,
> 
> Brandon

Hi, Brandon

I’m pretty new to ruby and rails. I’ve been working with IBM mid range  
for some 30yrs. I’m try to prove the concept of using ruby and rails for  
some new development and am quite comfortable with ruby and rails.  
However, I’ve not be able to access data on our iSeries. Is there any  
chance you could provide and example?

Thanks

Bob Nicholson
