Skip to content

Database Connections

Database functions such as DB Read, DB Write and Lookups need a connection string to connect to the target database.

A connection string provides the details necessary to find and authenticate with the database.

The DB Read and DB Write transforms and Lookups can each define their own connection string. Defining a database connection here lets several integrations and lookups reuse the same connection.

A Database Reader's Options tab, with the Database Connection/Connection String drop-down open. It lists the connections defined under Setup — ORACLE_ODBC_CONNECT, Orders Staging Database and Sage300 — over the SQL statement, a Query Timeout of 30 seconds and its warning about long-running queries, and a collapsed Hierarchical Dataset Options section

Setup > Database Connections

The Details of ORDERSDB dialog for a saved database connection: a read-only Id, the Description Orders database, and a Connection String naming an ODBC driver, the server sql.example.com, the database Orders and the user iman, with the password shown as Pwd= followed by eight asterisks and the characters a55. A Show secrets button with an eye icon sits under the box, above a TEST button

ID

A unique Id for the specified Database connection.

Description

A useful description for this connection.

Connection String

The connection string to find and authenticate the database.

The connection string must be in ODBC format. Native .NET connection strings are not valid.

IMan masks the secrets in a saved connection string. The value of Pwd, Password or another secret key, such as AccountKey or ApiKey, shows as ********, followed by the last three characters when the value is eight or more characters long. A Show secrets button appears under the box when the string holds a secret. Press it to show the stored values, and press Hide secrets to mask them again. Showing them needs the Can reveal a stored secret in full permission. You can edit the rest of the string while the mask is in place. IMan keeps the stored value until you type a new one over the mask.

A good resource for constructing connection strings is: http://www.connectionstrings.com/

Parameterised Connection Strings

You can parameterise the connection string to connect to different databases dynamically.

Parameters take the form %[1], %[2].

For example, the connection string below parameterises the Database value with %[1]. When the connection string is parameterised, Test lets you enter a value.

A database connection dialog with the connection string parameterised: the database name is replaced by the placeholder %[1], and a Parameter - 1 box beneath it supplies the value

Retry Settings

The retry settings above Test decide how IMan handles a database call that fails for a reason that may pass, such as a connection the network dropped or a server that is briefly unavailable. They apply to every reader, writer and lookup that uses this connection.

The retry settings on the Database Connection form: Custom retry settings unticked, and greyed beneath it Retries 3, First delay (seconds) 2 and Maximum delay (seconds) 8

Custom retry settings decides where the values come from. Unticked, IMan uses its defaults for a database connection, shown greyed in the boxes. A later release that improves the defaults changes an unticked record too. Tick it to edit the boxes and keep your own values on this record.

  • Retries: how many times IMan retries a failed call before it reports the error, from 0 to 5. 0 turns these retries off.
  • First delay (seconds): the wait before the first retry, from 1 to 60.
  • Maximum delay (seconds): the longest wait between retries, from 1 to
  • It cannot be less than the first delay.

Each wait is double the one before, up to the maximum delay. IMan varies every wait by up to a quarter either way. That keeps many callers from retrying in step.

The defaults for a database connection are 3 retries, a first delay of 2 seconds and a maximum delay of 8 seconds. The waits are then about 2, 4 and 8 seconds.

What IMan retries

IMan reads the error's SQLSTATE, the code the ODBC or OLE DB driver reports. It retries:

  • opening the connection, for a connection failure (any SQLSTATE in class 08) or a timeout (HYT00, HYT01), for readers, writers and lookups alike;
  • a reader's query that fails before it has returned its first row, for a connection failure. IMan reopens the connection first;
  • a lookup's query whose connection has dropped. IMan reopens the connection and runs the query again.

Two fixed rules cover a reader's query as well. A query the server chose as a deadlock victim (40001) runs again up to 3 times, after about half a second, 1 and 2 seconds. A query that timed out (HYT00) runs again once, after 2 seconds. Both apply whatever Retries says.

IMan never retries:

  • a rejected login (28000);
  • an error in the SQL, such as a syntax error or a missing table or column (class 42);
  • any other error;
  • a writer's insert, update or upsert. A lost connection there may already have committed the record. The record fails as it would without retries.

Keep a reader's query to a SELECT

A reader's query can run twice after a timeout. A stored procedure or a statement that changes data could then make its change twice. Put only a SELECT in a reader.

A connection string typed into a reader, writer or lookup instead of chosen from this list uses the defaults.

What you see

When a retry succeeds, the run carries on as if nothing had failed. Each retry writes a line to the transform's trace:

Attempt [1] of [4] failed; retrying in [4.8] s. <the error>

When the retries run out, IMan reports the last error with the count added, such as (after [3] retries), and the usual error handling applies. From then on, each call on the same reader, writer or lookup gets one attempt and no retries until a call succeeds. A server that is down then fails the remaining work quickly, rather than holding up every record for the full retry time.

IMan makes no retries in the Designer. A preview, or Test on this screen, reports the first failure at once.

Test

Press Test to check that the connection string is valid and working. A green tick on the button means IMan opened the connection. A red cross means it could not, and the database driver's error appears to the right of the button.