Active record - Oracle DATE/TIMESTAMP issue


I am new to active record so apologies for the newbie question, but I am
trying to set it up to access an Oracle database. Please note, this not
a rails app and never will be. I want to use JRuby to write dashboard
scripts for monitoring an number of back-end ETL data interfaces for
which I am primarily responsible.

My config is as follows:

Client PC running Windows
JRuby 1.2.0
Java 1.6.0_07
Oracle driver - ojdbc14.jar

Remote database hosted on Solaris
Oracle 10.2.03

My problem is that active record is failing to typecast date and time
fields at all.

For example, the following cutdown example attempts to access ‘RUN_DT’
which is defined in the database as a DATE (I am seeing the same issue
on TIMESTAMP fields too)…

require ‘java’
require ‘ojdbc14.jar’

puts “Starting active record”
require ‘rubygems’
gem ‘activerecord-jdbc-adapter’
require ‘jdbc_adapter’
require ‘active_record’

puts “Connecting to MXGN”
:adapter => ‘jdbc’,
:driver => ‘oracle.jdbc.OracleDriver’,
:url => ‘jdbc:oracle:thin:@MYHOST:1550:THEDB’,
:username => ‘FOO’,
:password => ‘bar’
puts “Running a query”

class TblMigrationWork < ActiveRecord::Base
set_table_name “tblmigrationwork”

result = TblMigrationWork.find(:first, :conditions => ‘run_id = 1’)
puts result.run_dt


Starting active record
Connecting to MXGN
Running a query
method_missing': undefined methodstring_to_time’ for
#Class:0x755866 (NoMethodError)
string_to_time' from C:/gems/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:211:inrun_dt’
from H:\sandbox\DBPlay\lib\main.rb:25

I can query VARCHAR and NUMERIC fields with no problems.

I have had a good look round the forums but I cannot find any reference
to this kind of problem. Can you please suggest a solution or where the
problem may be ocurring?

Many Thanks


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs