Hi,I really need your help.I have a program when I use ruby to conncet
oralcle DB.My code is(testdb.rb):

require 'rubygems'
require 'dbi'
puts "Begin Conn!"
dbh=DBI.connect('DBI:OCI8:orcl','sgpm','sgpm')
puts "connect db is OK!"
dbh.disconnect

My system is solaris,usually,when i input:"ruby testdb.rb" in the
terimnate it will print connect db is OK! quickly,but sometimes when it
print "Begin Conn",the system will wait for several minutes then have
the follow message:
env.c:257:in oci8lib.so: ORA-12170: TNS:Connect timeout occurred
(DBI::DatabaseError)
        from /usr/local/lib/ruby/site_ruby/1.8/oci8.rb:229:in
`initialize'
        from /usr/local/lib/ruby/site_ruby/1.8/DBD/OCI8/OCI8.rb:156:in
`new'
        from /usr/local/lib/ruby/site_ruby/1.8/DBD/OCI8/OCI8.rb:156:in
`connect'
        from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:448:in `connect'
        from /usr/local/lib/ruby/site_ruby/1.8/dbi.rb:221:in `connect'
        from testdb.rb:7

I have tried to use timeout() function to contorl the time,but it has no
use.
can you help me?(i want to control the code to excute in 5 secs,when it
didn't connect to DB in 5 seconds,then it should exit.)
Thanks very much!!!
-- 
Posted via http://www.ruby-forum.com/.