# simple.rb - simple MySQL script using
php?name=Ruby" onclick="tagshow(event)" class="t_tag">Ruby DBI module
require "dbi"
begin
# connect to the MySQL server
dbh = DBI.connect("dbi:Mysql:test:localhost", "root", "123")
# get server version string and display it
row = dbh.select_one("SELECT VERSION()")
puts "Server version: " + row[0]
rescue DBI:

atabaseError => e
puts "An error occurred"
puts "Error code: #{e.err}"
puts "Error message: #{e.errstr}"
ensure
# disconnect from server
dbh.disconnect if dbh
end
出错报.
.. ...in `load_driver': is not a cl
ass/module (TypeError)
from c:/bin/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:401:in `_get_full_dri
ver'
from c:/bin/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:381:in `connect'
希望大家帮帮忙