ActiveRecord JDBC adapter as Rails plugin

Posted by Nick Sieger Mon, 26 Jun 2006 17:53:00 GMT

I’ve got things set up in my svn repo such that you pull down my ActiveRecord JDBC adapter as a Rails plugin. Although it appears that using ‘script/plugin’ inside of JRuby may have some issues. So for now, use C Ruby. Inside your Rails app, do:

ruby script/plugin install

This should pull down and configure the JDBC adapter for you with no additional setup. If it doesn’t, let me know and we’ll work through it. I haven’t yet tried running a Rails app inside of JRuby yet but I hope to in the next couple of days.

I am also starting to investigate testing with another database, hsqldb. I think the driver could benefit from attempting to use some additional databases, if we’re ever going to fulfill the promise of leveraging any JDBC data source, and also I think it would be cool to use an embedded database in the spirit of SQLite which has become popular with smaller Rails apps in C Ruby-based Rails land.

Update: it turns out you can’t easily install a new ActiveRecord adapter as a Rails plugin at this point with out some extra finagling, because of the way Rails::Initializer initializes the database before any of the plugins. For now, I’ve got the plugin set up to re-initialize all of the ActiveRecord infrastructure, so in order to use the JDBC adapter plugin, you’ll need to add the following to your config/environment.rb. Note that you’re not “skipping” ActiveRecord, just initializing it later.

  # Skip frameworks you're not going to use
  config.frameworks -= [:active_record]

Posted in , ,  | 3 comments | no trackbacks


  1. Avatar Manyi Lu said 51 days later:

    A JDBC adapter is very useful.

    If you are going to test with additional databases, Java DB or Apache Derby is a good choice, it runs in both embedded and client server mode. Java DB actually comes with jdk1.6.

  2. Avatar Hasan said 73 days later:

    I’m trying to use this adapter with rails (rev. 5505). I put in “adapter: jdbc” into config/database.yml; I get “no such file to load -- java” from rake. There’s no gem named java either. The jvm is on my path. Do I need to install jruby?

  3. Avatar Nick said 73 days later:

    Yes, you do. I appear to have mixed usages of Ruby a little too much in the article. Try it with JRuby, or better yet, follow along with more recent howtos on using the AR-JDBC adapter. Have fun!


Use the following link to trackback from your own site: