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
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 J.’, :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
’
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