Advertisement
Guest User

Untitled

a guest
Dec 28th, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #!/usr/bin/ruby -w
  2. # simple.rb - simple MySQL script using Ruby MySQL module
  3.  
  4. require "mysql"
  5.  
  6. begin
  7. # connect to the MySQL server
  8. dbh = Mysql.real_connect("localhost", "testuser", "testpass", "test")
  9. # get server version string and display it
  10. puts "Server version: " + dbh.get_server_info
  11. rescue Mysql::Error => e
  12. puts "Error code: #{e.errno}"
  13. puts "Error message: #{e.error}"
  14. puts "Error SQLSTATE: #{e.sqlstate}" if e.respond_to?("sqlstate")
  15. ensure
  16. # disconnect from server
  17. dbh.close if dbh
  18. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement