title: How to connect to Oracle using JRuby & JDBC
body: <p>First approach: bare metal</p>
  
  <pre><code>require 'java'
  require 'rubygems'
  require "c:/ruby/jruby-1.2.0/lib/ojdbc14.jar"  # should be redundant, but tried it anyway
  odriver = Java::JavaClass.for_name("oracle.jdbc.driver.OracleDriver")
  puts odriver.java_class
  url = "jdbc:oracle:thin:@myhost:1521:mydb"
  puts "About to connect..."
  con = java.sql.DriverManager.getConnection(url, "myuser", "mypassword");
  if con
      puts " connection good"
  else
      puts " connection failed"
  end
  </code></pre>
  
  <p>The result of the above is:</p>
  
  <pre><code>sqltest.rb:4: cannot load Java class oracle.jdbc.driver.OracleDriver (NameError)
  </code></pre>
  
  <p>Second approach: Active Record</p>
  
  <pre><code>require 'rubygems'
  gem 'ActiveRecord-JDBC'
  require 'jdbc_adapter'
  require 'active_record'
  require 'active_record/version'
  require "c:/ruby/jruby-1.2.0/lib/ojdbc14.jar"  # should be redundant...
  
  ActiveRecord::Base.establish_connection(
     :adapter =&gt; 'jdbc',
     :driver =&gt; 'oracle.jdbc.driver.OracleDriver',
     :url =&gt; 'jdbc:oracle:thin:@myhost:1521:mydb',
     :username=&gt;'myuser',
     :password=&gt;'mypassword'
   )
  ActiveRecord::Base.connection.execute("SELECT * FROM mytable")
  </code></pre>
  
  <p>The result of this is:</p>
  
  <pre><code>C:/ruby/jruby-1.2.0/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9.1/lib/active_recordconnection_adapters/jdbc_adapter.rb:330:in `initialize': 
  The driver encountered an error: cannot load Java class oracle.jdbc.driver.OracleDriver (RuntimeError)
  </code></pre>
  
  <p>Essentially the same error no matter how I go about it.</p>
  
  <p>I'm using JRuby 1.2.0 and I have ojdbc14.jar in my JRuby lib directory</p>
  
  <p>Gems:</p>
  
  <ul>
  <li>ActiveRecord-JDBC (0.5)</li>
  <li>activerecord-jdbc-adapter (0.9.1)</li>
  <li>activerecord (2.2.2)</li>
  </ul>
  
  <p>What am I missing?</p>
  
  <p>Thanks,</p>