Digital Sanctum

software development, technology and other square topics

Archive for August, 2007

Connecting to Oracle from Rails

with 2 comments

Since there are several variations of docs on this (some of which are out of date) I figured I'd document this.

  1. Download and install the Ruby interface from http://rubyforge.org/projects/ruby-oci8/
  2. Then, in your config/database.yml file, you should have something like this:
CODE:
  1. development:
  2.    adapter: oracle
  3.    database: <your-sid-here>
  4.    host: //<your-host-here>:<your-port-here>
  5.    username: <your-username-here>
  6.    password: <your-password-here>

If you're running Rails with JRuby you should have the Oracle JDBC drivers in the classpath and the entry above will be a little different:

CODE:
  1. common: &shared
  2.    adapter: jdbc
  3.    driver: oracle.jdbc.driver.OracleDriver
  4.    url: jdbc:oracle:thin:@<your-host-here>:<your-port-here>:<your-sid-here>
  5.    username: <your-username-here>
  6.    password: <your-password-here>
  7.  
  8. # oracle (JDBC)
  9. development:
  10.    <<: *shared

Written by Shane

August 1st, 2007 at 2:23 pm