amowat
|
Posted: April 14, 2009 09:17 by amowat
|
|
Hi, 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 activerecord-2.3.2 activerecord-jdbc-adapter-0.9.1 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" ActiveRecord::Base.establish_connection( :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" end result = TblMigrationWork.find(:first, :conditions => 'run_id = 1') puts result.run_dt Produces.... Starting active record Connecting to MXGN Running a query C:/gems/gems/activerecord-2.3.2/lib/active_record/base.rb:1964:in `method_missing': undefined method `string_to_time' for #<Class:0x755866> (NoMethodError) from C:/gems/gems/activerecord-jdbc-adapter-0.9.1/lib/jdbc_adapter/jdbc_oracle.rb:58:in `string_to_time' from C:/gems/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:211:in `run_dt' from C:/gems/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:244:in `method_missing' 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 Adrian |
Oracle issue
Replies: 1 - Last Post: April 28, 2009 18:36
by: Nick Sieger
by: Nick Sieger
showing 1 - 2 of 2
Nick Sieger
|
Posted: April 28, 2009 18:36 by Nick Sieger
|
|
Hi Adrian, Sorry for not replying to the post sooner. We've had a few Oracle issues reported lately, and I suspect we may have regressed a bit in the 0.9.1 release as we shuffled around a bunch of internals. In fact, there are currently some date-related tests failing in trunk for Oracle, the last time I checked. Can you see if perhaps any of those test cases replicate your issue, and if not, would you be willing to distill a test case for us and maybe even see if you can find the offending code? If you get the source code, you should be able to just run jruby -S rake test_oracle, assuming you add ojdbc14.jar to the classpath and can set up a test tablespace per the instructions in test/db/oracle.rb. Let us know how you go, /Nick |
Replies: 1 - Last Post: April 28, 2009 18:36
by: Nick Sieger
by: Nick Sieger







