Hi,
I'm rather new to Ruby and RoR, so I do not really know whether this ist the right forum to place my question.
For my first 'project' I planned to create a simple online-viewer, which grabs data from an existing database and make them visible in a structured form via browsers. So I thought that could be the right beginner-project, because I have only read datasets without any editing or creating.
The existing database is a very old one (Pervasive 8.7) and the db-design is poor, but that is all I have and I have to live with it.
Fortunately there are JDBC-Drivers, so a connection via activerecord-jdbc-adapter will work... I thought.
Within the services of Netbeans using those JDBC-Drivers I'm able to establish a connection to the database and the IDE shows me all available tables and there referring datasets.
The content of database.yml is only:
development: adapter: jdbc username: password: driver: com.pervasive.jdbc.v2.Driver url: jdbc:pervasive://192.168.0.130:1583/database
No test-db and no production-db, because the development-db is read-only.
After putting these tow lines into the environment.rb:
$CLASSPATH << "file:///#{Rails.root}/lib/java/pvjdbc2.jar" $CLASSPATH << "file:///#{Rails.root}/lib/java/pvjdbc2x.jar"
the application started with webrick gives no error-message, so I think, that the JDBC-drivers are loaded correctly.
Now I made a model mandate_file.rb which contains
class MandateFile < ActiveRecord::Base
# fix non-standard table and primary key name conventions set_table_name "STAMM" set_primary_key :D_LFDNR
# fix the upper-cased named columns alias_attribute :id, :D_LFDNR alias_attribute :annotext_az, :D_AZ alias_attribute :name_creditor, :D_RUBGE
end
When I try to create a simple object via the console using "m = MandateFile.new" I get the following list of errors:
ActiveRecord::JDBCError: Invalid column number from arjdbc/jdbc/RubyJdbcConnection.java:121:in `columns' from c:/jruby/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-1.1.1/lib/arjdbc/jdbc/adapter.rb:229:in `jdbc_columns' from c:/jruby/lib/ruby/gems/1.8/gems/activerecord-3.0.7/lib/active_record/base.rb:680:in `columns' from c:/jruby/lib/ruby/gems/1.8/gems/activerecord-3.0.7/lib/active_record/persistence.rb:284:in `attributes_from_column_definition' from c:/jruby/lib/ruby/gems/1.8/gems/activerecord-3.0.7/lib/active_record/locking/optimistic.rb:62:in `attributes_from_column_definition' from c:/jruby/lib/ruby/gems/1.8/gems/activerecord-3.0.7/lib/active_record/base.rb:1395:in `initialize' from (irb):1:in `evaluate' from org/jruby/RubyKernel.java:1088:in `eval' from C:/jruby/lib/ruby/1.8/irb.rb:158:in `eval_input' from C:/jruby/lib/ruby/1.8/irb.rb:271:in `signal_status' from C:/jruby/lib/ruby/1.8/irb.rb:155:in `eval_input' from org/jruby/RubyKernel.java:1418:in `loop' from org/jruby/RubyKernel.java:1191:in `catch' from C:/jruby/lib/ruby/1.8/irb.rb:154:in `eval_input' from C:/jruby/lib/ruby/1.8/irb.rb:71:in `start' from org/jruby/RubyKernel.java:1191:in `catch' from C:/jruby/lib/ruby/1.8/irb.rb:70:in `start' from c:/jruby/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands/console.rb:44:in `start' from c:/jruby/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands/console.rb:8:in `start' from c:/jruby/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:23:in `(root)' from org/jruby/RubyKernel.java:1038:in `require' from script\rails:6:in `(root)
I've googled for 'Invalid column number' but found nothing, what might be helpful.
I think, that I make a very simple mistake, but I've no idea about it. Are there any hints for me?
Thanks in advance!
Klaus