The error shows as below
F:\rbtest>ruby 2.rb
Server version: 4.1.11-nt
c:/program files/ruby/lib/ruby/site_ruby/1.8/DBD/Mysql/Mysql.rb:403:in `execute'
: #3D000No database selected (DBI::DatabaseError)
from c:/program files/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:768:in `exe
cute'
from 2.rb:18
Server version: 4.1.11-nt
c:/program files/ruby/lib/ruby/site_ruby/1.8/DBD/Mysql/Mysql.rb:403:in `execute'
: #3D000No database selected (DBI::DatabaseError)
from c:/program files/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:768:in `exe
cute'
from 2.rb:18
F:\rbtest>
The code 2.rb is as below
require "dbi"
begin
# connect to the MySQL server
# dbh = DBI.connect("dbi:Mysql:test:localhost", "root", "000000")
dbh = DBI.connect("dbi:Mysql:jim_opsuite:192.168.0.5", "jim", "123456")
# get server version string and display it
row = dbh.select_one("SELECT VERSION()")
puts "Server version: " + row[0]
rescue DBI::DatabaseError => e
puts "An error occurred"
puts "Error code: #{e.err}"
puts "Error message: #{e.errstr}"
ensure
# disconnect from server
sth=dbh.prepare('sel! ect * from user')
sth.execute
while row=sth.fetch do
puts row
end
dbh.disconnect if dbh
end
# connect to the MySQL server
# dbh = DBI.connect("dbi:Mysql:test:localhost", "root", "000000")
dbh = DBI.connect("dbi:Mysql:jim_opsuite:192.168.0.5", "jim", "123456")
# get server version string and display it
row = dbh.select_one("SELECT VERSION()")
puts "Server version: " + row[0]
rescue DBI::DatabaseError => e
puts "An error occurred"
puts "Error code: #{e.err}"
puts "Error message: #{e.errstr}"
ensure
# disconnect from server
sth=dbh.prepare('sel! ect * from user')
sth.execute
while row=sth.fetch do
puts row
end
dbh.disconnect if dbh
end
This code can run correctly with the Mysql 4.0.XX
I am using the patch
to update the ruby_mysql to support the Mysql 4.1.XX
after patching that patch I run the 2.rb for testing
but the error above was printed.
So does anybody meet this problem before?
Any advice is appriciated
Thank you
jim
Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort.
_______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
