DBI Connect failure - can we retry please?

D

Dave Smith

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
 
M

Michael Glaesemann

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 Glaesemann
grzm seespotcode net
 
D

Daniel Berger

-----Original Message-----
From: (e-mail address removed) [mailto:[email protected]]
Sent: Tuesday, May 26, 2009 6:30 AM
To: ruby-talk ML
Subject: DBI Connect failure - can we retry please?
=20
Hi Guys,
=20
I got a DBI connection that tries to connect to a source that = sometimes
has an unreliable connection behind it.
=20
DBH =3D DBI.connect('dbi:ODBC:conenction_name', 'username', = 'password')
=20
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.
=20
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 =3D DBI.connect(...) }

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

Regards,

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,083
Members
48,773
Latest member
Kaybee

Latest Threads

Top