Hi All,

I need your help on some error message that I am getting. I am working
on cucumber with selenium to automate my application.
Now I am supposed to connect to a database and fetch value from there.
Since I am new to database connectivity stuff so please excuse me for my
silly mistake if any.

Here are all the steps that I followed

1.I installed MYSQL database on my system. The version is 5.1.32.
2.Then I installed MYSQL gem. The version is mysql (2.8.1 x86-mingw32).
3.I have ruby 1.9. I do not have anything related to ROR installed on my
system.
4.I used the steps given on
http://rubylearning.com/satishtalim/ruby_activerecord_and_mysql.html
and created a database with name students.Then I created a table
rubyists in this databse.

I created the ruby file to talk to the database. The code is

require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection({
:adapter=> "mysql",
:host => "localhost",
:username => "root",
:password => "namitjain",
:database=> "students"

})

class Rubyist < ActiveRecord::Base
end


Rubyist.create(:name => 'Luc Juggery', :city => "Nashville, Tenessee")
Rubyist.create(:name => 'Sunil Kelkar', :city => "Pune, India")
Rubyist.create(:name => 'Adam Smith', :city => "San Fransisco, USA")

participant = Rubyist.find(:first)
puts %{#{participant.name} stays in #{participant.city}}

Rubyist.find(:first).destroy



But when I execute this file from command prompt i get the following
error:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/mysql_adapter.rb:144:in
`each_hash': NULL pointer given (ArgumentE
ror)
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/mysql_adapter.rb:144:in
`each_hash'
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:427:in
`each'
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:427:in
`map'
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:427:in
`block in columns'
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/mysql_adapter.rb:325:in
`execute_and_free'
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:426:in
`columns'
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/schema_cache.rb:12:in
`block in initialize'
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:228:in
`yield'
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:228:in
`default'
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:228:in
`columns'
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:243:in
`column_defaults'
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/base.rb:482:in
`initialize'
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/persistence.rb:44:in
`new'
from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/persistence.rb:44:in
`create'
from p080dbconnect.rb:15:in `<main>'

Please help me out and let me know if I am missing on any step that is
required for the correct step. Any input will be of great help.

Thanks in Advance,
Namit Jain

--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Namit j. at Sep 6, 2012 at 9:23 am
    Hi All,

    I just got it working by replacing the libmySQL.dll in bin directory of
    my Ruby folder. I referred to the link
    http://fuyun.org/2010/01/ruby-mysql-adapter-on-windows/ and downloaded
    the new dll from
    http://www.dll-files.com/dllindex/dll-files.shtml?libmysql.
    This might be a compatibility issue.

    Thanks,
    Namit

    --
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedSep 5, '12 at 12:28p
activeSep 6, '12 at 9:23a
posts2
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Namit j.: 2 posts

People

Translate

site design / logo © 2021 Grokbase