In order to establish a connection with the database, users must create an object that will manage all of that connection’s important attributes. In Teradata PT, this object is called a Connection object.
There are two steps involved in building a Connection object:
- Create a Connection Object
The Connection object is defined as a C++ class. A Connection object can be created by calling the Connection class constructor.
using namespace teradata::client::API; Connection* conn = new Connection();
- Add ParametersThe Connection object is used to house parameters for a database connection. There are three types of parameters:
- DML Groups
There are various types of options that can be set using attributes. Each driver has a set of required attributes and optional attributes. Depending on the attribute, there can be multiple values for that attribute. These are called array attributes. The following is an example of adding attributes and array attributes:
conn->AddAttribute(TD_MAX_SESSIONS,4); conn->AddArrayAttribute(TD_WORK_TABLE, 2,"testa_wt","testb_wt", NULL);
Set the values for an attribute in a single call to either the AddAttribute function or the AddArrayAttribute function. Once an attribute has been set, the values of the attribute cannot be changed and additional values cannot be added to it.
Set all attributes prior to calling the Initiate function. After a Connection object has been initiated, no additional attributes may be set.