Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Temporary database connection errors are common when working with databases and can often be resolved by retrying after a delay.

The db2 library expands the built-in db table of functions by incorporating the retry functionality from the https://docs.interfaceware.com/docs/IguanaX_Documentation_Home/Development/iNTERFACEWARE_Libraries/Retry_Library_2713911370 into the standard database functions. The db2.connect() function sets up the database connection object with built-in whenever an error occurs. It takes the same arguments as the default db.connect() function, with two additional optional parameters:

  • retry_count - sets the number of retries to perform on the database connection (default = 100)

  • retry_pause - sets the time in seconds to wait between retries (default = 10)

For example, here the we are initializing the database connection object with 10 retries and a pause of five seconds between each call:

local Conn = db2.connect{api=db.MY_SQL,name='MyDatabase',user='me',password='secret',retry_count=10,retry_pause=5}

Note: By default if the retries fail, an error will be thrown which will (usually) stop the channel.

You can import this library to add resiliency to your database interfaces. See how to Import a Library.

  • No labels