ActiveRecordError in 'columns' when working with Oracle


#1

I have deployed a jruby app in tomcat (5.5, JVM 1.5). The app runs fine
when
using a mysql db but with Oracle (10g) it apparently is not able to read
the
columns.

My database connection settings:
adapter: jdbc
driver: oracle.jdbc.driver.OracleDriver
url: jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST

myHost)(PORT = 1523)) (CONNECT_DATA =(SERVICE_NAME = mySID)))
username: username
password: password

I use Rails 2.1.0 (due to some other issue I had).

The error message is, unfortunately, not very detailled. I wonder if
this is
somehow connected to Oracle using capital letters for column names. I
tried
‘table_exists?’ and that returns true. Running ‘columns’ then produces
the
same error. I also tried for ‘attribute_names’ but I cannot create the
necessary instance. Any suggestions would be very much appreciated.

Here, now, is the error that I get:

ActiveRecord::ActiveRecordError in UploadsController#index

No message available

RAILS_ROOT: /opt/inst/apache/tomcat_5.5.26/webapps/coopapp/WEB-INF

Application Trace | Framework Trace | Full Trace

/opt/inst/tomcat/webapps/coopapp/WEB-INF/gems/gems/activerecord-2.1.0/lib/active_record/base.rb:1145:in
columns' /opt/inst/tomcat/webapps/coopapp/WEB-INF/gems/gems/activerecord-2.1.0/lib/active_record/base.rb:2598:inattributes_from_column_definition’
/opt/inst/tomcat/webapps/coopapp/WEB-INF/gems/gems/activerecord-2.1.0/lib/active_record/locking/optimistic.rb:55:in
attributes_from_column_definition /opt/inst/tomcat/webapps/coopapp/WEB-INF/gems/gems/activerecord-2.1.0/lib/active_record/base.rb:2126:ininitialize’
app/controllers/uploads_controller.rb:71:in index' /opt/inst/tomcat/webapps/coopapp/WEB-INF/gems/gems/actionpack-2.1.0/lib/action_controller/base.rb:1162:inperform_action’
/opt/inst/tomcat/webapps/coopapp/WEB-INF/gems/gems/actionpack-2.1.0/lib/action_controller/filters.rb:580:in
`call_filters’


View this message in context:
http://www.nabble.com/ActiveRecordError-in-'columns'-when-working-with-Oracle-tp23062247p23062247.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#2

I am getting really desperate with this error. Will have to throw my
whole
Rails project away and do it all in Java if I cannot get this solved …
bad
thing.
What I did in the meantime:

  • Updating to jruby 1.2 and rails 2.2.2, activerecord-jdbc-adapter
    (0.9.1).
    All fine on my test system (same setting but mysql-db). Problem persists
    with the Oracle 10g.
  • Debugging jdbc - apparently no SQL-statement is being sent by
    ‘myObject.columns’, or the error occurs before that. General select
    statements are successful: ‘myObject.find(:all)’. It is only the columns
    information that somehow cannot be read.
  • Running a test with (ActiveRecord::Base)connection.execute(“insert
    into
    extensions (ID, NAME) values (‘1’, ‘pdf’)”) worked fine.

So, I wonder if there is anything left I can try:
Maybe provide the columns information by hand? But of what Class should
they
be? In my test system, running with MySQL, they are
ActiveRecord::ConnectionAdapters::MysqlColumn
Or run another adapter? But is there any alternative to jdbc? Even a bad
one?

Here is the stack trace I get after the latest changes (basically the
same
as before):

ActiveRecord::ActiveRecordError (No message available):

/opt/HRVE/tomcat/webapps/coopapp/WEB-INF/gems/gems/activerecord-2.2.2/lib/active_record/base.rb:1232:in
`columns’

/opt/HRVE/tomcat/webapps/coopapp/WEB-INF/gems/gems/activerecord-2.2.2/lib/active_record/base.rb:2851:in
`attributes_from_column_definition’

/opt/HRVE/tomcat/webapps/coopapp/WEB-INF/gems/gems/activerecord-2.2.2/lib/active_record/locking/optimistic.rb:55:in
`attributes_from_column_
definition_with_lock’

/opt/HRVE/tomcat/webapps/coopapp/WEB-INF/gems/gems/activerecord-2.2.2/lib/active_record/base.rb:2291:in
initialize' /app/controllers/uploads_controller.rb:75:inindex’

/opt/HRVE/tomcat/webapps/coopapp/WEB-INF/gems/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
`perform_action’

/opt/HRVE/tomcat/webapps/coopapp/WEB-INF/gems/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in
`call_filters’

View this message in context:
http://www.nabble.com/ActiveRecordError-in-'columns'-when-working-with-Oracle-tp23062247p23197412.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#3

On Thu, Apr 23, 2009 at 10:30 AM, kaey-7 removed_email_address@domain.invalid wrote:

statements are successful: ‘myObject.find(:all)’. It is only the columns

Here is the stack trace I get after the latest changes (basically the same
as before):

ActiveRecord::ActiveRecordError (No message available):

/opt/HRVE/tomcat/webapps/coopapp/WEB-INF/gems/gems/activerecord-2.2.2/lib/active_record/base.rb:1232:in
`columns’

I haven’t heard of anyone seeing this issue with Oracle before. We
have unit tests that are working that definitely are using the
#columns method and discovering columns, so I suspect something on
your end. How are you configuring the database?

Some things to try:

  • Check your app’s codebase to see if there happen to be any
    conflicting methods named #columns or column_names in your models
  • Do you get the same error if you run the app using Mongrel or Webrick?
  • Do you get the same error in the Rails console?

Cheers,
/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#4

Also are you using any reserved words in your schema
(http://wiki.rubyonrails.org/rails/pages/ReservedWords)?

On Thu, Apr 23, 2009 at 2:12 PM, Nick S. removed_email_address@domain.invalid
wrote:

‘myObject.columns’, or the error occurs before that. General select
one?
have unit tests that are working that definitely are using the
/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#5

Many thanks for your replies.

I had no columns method. I have written one now creating
ActiveRecord::ConnectionAdapters::Column objects. It is not an elegant
solution but it seems to help.

  • There is no direct access to the Oracle db. It is a customer’s system
    and
    all I have is an sqlplus connection.
  • I deploy the app in a tomcat. There is no Rails environment there, so
    no
    console, other servers or anything. I test on a rather similar system,
    however, and there everything is fine. Only difference is the database
    (mysql).

The idea with the forbidden names is a good one. I actually have a
column
with the name “data”. I need it for attachment_fu with :storage =>
:db_file.
Apparently, the table db_files must have a column of that name. Not sure
how
easily that can be modified. Then again, I would expect other users to
run
into the same problem. Does anybody run attachment_fu with db storage on
an
Oracle?


View this message in context:
http://www.nabble.com/ActiveRecordError-in-'columns'-when-working-with-Oracle-tp23062247p23213787.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#6

Yesterday I finally got it all to work. I have modified the
attachment_fu to
work with a blob column with a different name (by modifying
attachment_fu/lib/technoweenie/attachment_fu/backends/db_file_backend.rb).
With the column name ‘data’ storing blob data into the db did not work.
The
manual column definition, however, was still necessary after that
change.
So, my definition of the DbFile model (which you need if you use
attachment_fu with :storage => db_file) looks like this:

class DbFile < ActiveRecord::Base
def self.table_name()
“my_db_files”
end
def self.columns()
@columns = []
@columns << ActiveRecord::ConnectionAdapters::Column.new(“id”, nil,
“int(30)”)
@columns << ActiveRecord::ConnectionAdapters::Column.new(“mydata”,
nil,
“blob”)
@columns
end
end

Not elegant at all but it works.
Funny enough the table_name definition works only with Jruby. In my
development environment (Rails, Ruby, Mongrel) the table is still
expected
to be named in the standard of attachment_fu (‘db_files’). So, maybe
this
class is not even read in this environment.

View this message in context:
http://www.nabble.com/ActiveRecordError-in-'columns'-when-working-with-Oracle-tp23062247p23294888.html
Sent from the JRuby - User mailing list archive at Nabble.com.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#7

One thing I would like to do for 0.9.2 is add
DatabaseMetadata.getSQLKeywords and probably also use
getIdentifierQuoteString() in some fashion to have generic keyword
protected and quoting logic for all adapters based on JDBC metadata.

-Tom

On Fri, Apr 24, 2009 at 5:53 AM, kaey-7 removed_email_address@domain.invalid wrote:

console, other servers or anything. I test on a rather similar system,


Blog: http://www.bloglines.com/blog/ThomasEEnebo
Email: removed_email_address@domain.invalid , removed_email_address@domain.invalid


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#8

Oliver Schwantje wrote:

We have the same problem with the columns-Method.
It works, if the table has no date-field. With a date-field
we get the same exception. If you can’t reproduce the error,
it may be a problem of different nls_date_format-Parameters.

ciao
oliver

And I know that it’s a problem the Java-Method:
jdbc_adapter.RubyJdbcConnection#columns_internal

bye
oliver


#9

We have the same problem with the columns-Method.
It works, if the table has no date-field. With a date-field
we get the same exception. If you can’t reproduce the error,
it may be a problem of different nls_date_format-Parameters.

ciao
oliver