在我的Windows 7盒子上,I ve安装了Rub.1.9.2,并安装了以下格米:
www.un.org/Depts/DGACM/index_french.htm
- dbd-mysql (0.4.4)
- dbi (0.4.5)
- deprecated (2.0.1)
- httparty (0.8.1)
- rubygems-update (1.8.15)
(我使用gem安装)。
我还编写了以下简单测试:
require rubygems
require dbi
begin
dbh = DBI.connect("DBI:Mysql:test", "username", "pwd")
row = dbh.select_one("SELECT VERSION()")
puts "Server Version: "+row[0]
rescue DBI::DatabaseError => e
puts "An error occurred"
puts "Error code: #{e.erriii"
puts "Error message: #{e.errstriii"
ensure
# disconnect from server
dbh.disconnect if dbh
end
不管我如何具体指明连接线,我还是要:
C:CodeConcordance.SE>ruby test_sql.rb
C:/Tools/Ruby192/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:300:in `block in
load_driver : Unable to load driver Mysql (underlying error: uninitialized con
stant DBI::DBD::Mysql) (DBI::InterfaceError)
from C:/Tools/Ruby192/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize
from C:/Tools/Ruby192/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:242:
in `load_driver
from C:/Tools/Ruby192/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:160:
in `_get_full_driver
from C:/Tools/Ruby192/lib/ruby/gems/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:145:
in `connect
from test_sql.rb:4:in `<main>
iii
我做了什么错误?