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.
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
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):
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?
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?
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.
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.
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
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.