Guest User

Untitled

a guest
Jan 25th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1.  
  2. require 'active_record'
  3. require 'tiny_tds'
  4.  
  5. ActiveRecord::Base.establish_connection(
  6. :host => "ltwpeter-vm-w7",
  7. :adapter => "sqlserver",
  8. :username => "aw_web",
  9. :password => "aw_web8245",
  10. :database => "AdventureWorks",
  11. :timeout => 5000 # blocking also occurs w/ :timeout => 5
  12. )
  13. SQL = ActiveRecord::Base
  14. start_time = nil
  15. begin
  16. start_time = Time.now
  17. puts "Starting ActiveRecord/SqlServer request"
  18. rows = SQL.connection.select_all("select count(column_name) as 'normal_count' from information_schema.columns")
  19. puts rows.inspect
  20.  
  21. puts "Now pausing VirtualBox VM... "
  22. puts %x/ VBoxManage controlvm "Windows 7" pause /
  23. sleep 2
  24. puts "Start time #{start_time}"
  25. puts "Check for active Connection: #{SQL.connection.active?} "
  26. puts "Then execute the request again with TinyTDS timeout ..."
  27. rows = SQL.connection.select_all("select count(column_name) as 'timeout_count' from information_schema.columns")
  28. puts rows.inspect
  29.  
  30. rescue Timeout::Error => time_e
  31. puts time_e.inspect
  32. rescue Errno::ETIMEDOUT => etimeout
  33. puts etimeout.inspect
  34. rescue Exception => e
  35. puts e.inspect
  36. ensure
  37. puts "End time #{Time.now} "
  38. puts "Total time for SQL request: #{start_time.nil? ? "error" : Time.now - start_time} "
  39. sleep 1
  40. puts "Now resuming VirtualBox VM... "
  41. puts %x/ VBoxManage controlvm "Windows 7" resume /
  42. end
  43. # # Total time for reqeust to 192.168.12.12: 74.629005
Add Comment
Please, Sign In to add comment