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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sent from my iPhone On May 7, 2011, at 2:51 PM, Klaus Humme <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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. >Check to make sure your columns in your model are correctly listed. It sounds like it is trying to use the id column or numerically increment a column that is not numeric. Also, if the database is read only then MandateFile.new is not going to work anyway since you won''t be able to save the record. B.> 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 > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Okay, I''ve choesen an other table with only 11 columns and listed them all: class MandateFile < ActiveRecord::Base # fix non-standard table and primary key name conventions set_table_name :AZLOELOG set_primary_key :D_AZLOGNR alias_attribute :id, :D_AZLOGNR alias_attribute :annotext_az, :D_AZLOAGAZ alias_attribute :name_debtor, :D_AZLOGRUB1 alias_attribute :name_creditor, :D_AZLOGRUB2 alias_attribute :delete_date, :D_AZLOGDAT alias_attribute :delete_user, :D_AZLOGUSER alias_attribute :not_used, :D_AZLOGFREE alias_attribute :log_sign, :D_AZLOGKE alias_attribute :delete_year, :D_AZLOGAZJAHR alias_attribute :delete_counter, :D_AZLOGAZZAEHL alias_attribute :reserved, :D_AZLOGRES end I''ve also switched the database access to ''read+write''. Column''s D_AZLOGNR datatype is integer. IMHO I did and checked all that Bryan told me, but the result is the same: ActiveRecord::JDBCError: Invalid column number Any mory suggestions? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On May 8, 3:36 am, Klaus Humme <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Okay, I''ve choesen an other table with only 11 columns and listed them > all: > > class MandateFile < ActiveRecord::Base > > # fix non-standard table and primary key name conventions > set_table_name :AZLOELOG > set_primary_key :D_AZLOGNR > > alias_attribute :id, :D_AZLOGNR > alias_attribute :annotext_az, :D_AZLOAGAZ > alias_attribute :name_debtor, :D_AZLOGRUB1 > alias_attribute :name_creditor, :D_AZLOGRUB2 > alias_attribute :delete_date, :D_AZLOGDAT > alias_attribute :delete_user, :D_AZLOGUSER > alias_attribute :not_used, :D_AZLOGFREE > alias_attribute :log_sign, :D_AZLOGKE > alias_attribute :delete_year, :D_AZLOGAZJAHR > alias_attribute :delete_counter, :D_AZLOGAZZAEHL > alias_attribute :reserved, :D_AZLOGRES > > end > > I''ve also switched the database access to ''read+write''. Column''s > D_AZLOGNR datatype is integer. IMHO I did and checked all that Bryan > told me, but the result is the same: ActiveRecord::JDBCError: Invalid > column number > > Any mory suggestions?Do you get the same behavior if you just call ''MandateFile.columns''? I suspect you will - this sounds like an issue with the JDBC driver rather than your code. You might want to try the AR-JDBC JIRA and/or mailing lists: http://kenai.com/jira/browse/ACTIVERECORD_JDBC --Matt Jones -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Matt Jones wrote in post #997376:> Do you get the same behavior if you just call ''MandateFile.columns''?Hi Matt, MandateFile.columns quits with RuntimeError: The driver encountered an unknown error: java.lang.NullPointerException: null> I suspect you will - this sounds like an issue with the JDBC driver > rather than your code.Maybe, but if its so, it must be in addition to activerecord, because I used the same JDBC driver several months ago to establish a connection through pure Java and I was able to query the database via simple SQL-Statements.> You might want to try the AR-JDBC JIRA and/or > mailing lists: > > http://kenai.com/jira/browse/ACTIVERECORD_JDBCThanks, I will take a look at these. Greetings Klaus> --Matt Jones-- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.