DBI Connect failure - can we retry please?


#1

Hi Guys,

I got a DBI connection that tries to connect to a source that sometimes
has an unreliable connection behind it.

DBH = DBI.connect(‘dbi:ODBC:conenction_name’, ‘username’, ‘password’)

It has failed a couple of times to connect and just bombs out the
script. As this is to be an automated script it would be nice to be able
to make a couple of attempts at trying to connect before bombing out.

Is anyone able to offer any code and advice as to how best to go about
this? I have looked online but the help is limited.

Many thanks in advance,

Roger


#2

On May 26, 2009, at 8:29 , Dave S. wrote:

It has failed a couple of times to connect and just bombs out the
script. As this is to be an automated script it would be nice to be
able
to make a couple of attempts at trying to connect before bombing out.

Is anyone able to offer any code and advice as to how best to go about
this? I have looked online but the help is limited.

begin/rescue with a counter?

Michael G.
grzm seespotcode net


#3

DBH = DBI.connect(‘dbi:ODBC:conenction_name’, ‘username’, ‘password’)

It has failed a couple of times to connect and just bombs out the
script. As this is to be an automated script it would be nice to be
able
to make a couple of attempts at trying to connect before bombing out.

Is anyone able to offer any code and advice as to how best to go about
this? I have looked online but the help is limited.

gem install attempt

attempt{ dbh = DBI.connect(…) }

See http://rubyforge.org/docman/view.php/735/485/README.html for more
details.

Regards,

Dan