activerecordjdbcjrubywarbler

Error using jRuby, warbler, active-record and oracle


I use warbler to make JAR files from my jRuby project. When i Run my code in jRuby itself like

jRuby.exe -S test_jdbc.rb 

everything works fine. When i warble it up and I have my test_jdbc.jar file i get an error while running the JAR.

The code that produces the error is

#table is in other scheme than the connected scheme so, i have to use both the scheme and the tablename
class Ondon < ActiveRecord::Base
  self.table_name    = 'xxxxxxxx.xxxxx'
  self.sequence_name = 'xxxxxxxx.xxxxxxx'
end

dossier = Ondon.where(rnr13: rnr, dossier_nr: dosnr)
p dossier

error: org.jruby.embed.EvalFailedException: (StatementInvalid) ActiveRecord::JDBCError: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

The sql that produces the error is like

SELECT "schemename"."tablename".* FROM "schemename"."tablename"  WHERE "schemename"."tablename"."fieldname" = .. etc

If i run this SQL in eg SqlPlus I get the same error

ORA-00942: table or view does not exist

If i remove the quotes around the scheme- table- and fieldnames in SqlPlus the sql runs fine.

How can I avoid this error ?

Here the programs and gems used

OS: Windows7
jdbcdriver: ojdbc6.jar
jRuby: 1.7.4
activerecord: 4.1.1
activerecord-jdbc-adapter: 1.3.11
warbler:1.4.4

Solution

  • you simply need to declare the correct case with self.table_name = 'xxxxxxxx.xxxxx' ... if it was created without quotes it's likely that the stored names are uppercase e.g. OTHER_SCHEMA.MY_TABLE