ODBC Connection Attributes
Use connection attributes to access client information with the ODBC application programming interface (API).
To set or get ODBC connection attributes that are specific to SAP HANA, first include "<client install directory>/sdk/odbc/incl/sqlsdbodbc.h".
The following tables list the SAP HANA client-specific and standard ODBC connection attributes.
SAP HANA Client-Specific ODBC Connection Attributes
|
Connection Attribute |
Type |
Description |
|---|---|---|
|
SQL_ATTR_AGGREGATE_TYPES |
SQLULEN |
Specifies aggregate types for expressions (AVG, SUM, and so on). 1 means like MS-SQL (for example, SUM(INTEGER) is of type INTEGER; otherwise, it would be FLOAT). |
|
SQL_ATTR_BYTES_SENT |
SQLBIGINT |
Retrieves the total number of the network bytes sent to the server since the database connection was established. The total sent bytes are reset to zero by the driver when the connection is disconnected. |
|
SQL_ATTR_BYTES_RECEIVED |
SQLBIGINT |
Retrieves the total number of the network bytes received from the server since the database connection was established. The total received bytes are reset to zero by the driver when the connection is disconnected |
|
SQL_ATTR_CODEPAGE |
SQLCHAR |
Specifies the codepage used for UCS2 to ASCII conversion. The codepage is selected from the database. In Microsoft Windows, the default codepage is the active codepage of the client. In non-Microsoft Windows operating systems, the default codepage is WINDOWS-1252. A codepage is valid for all connections of the affected driver. If SQLSetConnectAttr is called a second time with a different codepage, then the driver can crash if a conversion is running simultaneously. |
|
SQL_ATTR_DEFAULTMAPCHAR |
SQLCHAR |
Specifies the character representing non-convertible UCS2 characters in ASCII strings. This attribute only works if the SQL_ATTR_CODEPAGENAME attribute is set. If SQL_ATTR_CODEPAGENAME is not set, then a non-convertible UCS2 character causes a conversion error when converting to ASCII. Setting this attribute to '\0' disables this feature. The default setting is '?'. |
|
SQL_ATTR_ENCRYPT |
SQLULEN |
Specifies whether encryption is used for the connection. Returns 0 if encryption is not used. |
|
SQL_ATTR_TRACE_CALLBACK |
ODBC_TraceCallback |
Specifies a pointer to the callback method that receives connection trace messages. |
|
SQL_ATTR_TRACE_CALLBACK_CONTEXT |
SQLPOINTER |
Specifies a context pointer passed directly to the callback. |
|
SQL_ATTR_TRACE_CALLBACK_OPTIONS |
SQLCHAR |
Specifies a string describing the trace options to use for connection trace messages. See SQLDBC Trace Options |
|
SQL_ATTR_UNICODEDB |
SQLULEN |
Returns "SQL_TRUE" if the database supports Unicode, and "SQL_FALSE" otherwise (read-only). |
|
SQL_SQLDBC_BINTEXT_IS_NCLOB |
SQLULEN |
Tells the ODBC driver to report BINTEXT fields as either NCLOB (default, TRUE) or LONG VARBINARY (FALSE). |
|
SQL_SQLDBC_CHAR_AS_CESU8 |
SQLULEN |
Specifies the encoding of SQL_C_CHAR data is in CESU8. This attribute cannot be set if SQL_SQLDBC_CHAR_AS_UTF8 is set. |
|
SQL_SQLDBC_CHAR_AS_UTF8 |
SQLULEN |
Specifies whether SQL_C_CHAR data is handled as UTF8. This attribute cannot be set if SQL_SQLDBC_CHAR_AS_CESU8 is set. |
|
SQL_SQLDBC_GET_CLIENTINFO_VALUE |
SQLCHAR |
Retrieves the client information value for the key specified by the SQL_SQLDBC_SET_CLIENTINFO_KEY attribute. |
|
SQL_SQLDBC_PROXY_HOST |
SQLCHAR |
Specifies the host name of the proxy server. |
|
SQL_SQLDBC_PROXY_PORT |
SQLULEN |
Specifies the port of the proxy server. The port can be a value in the range of 1 and 65535. The default is 1080. |
|
SQL_SQLDBC_PROXY_SCP_ACCOUNT |
SQLCHAR |
Provides SAP Cloud Connector routing information to the Cloud Connector SOCKS proxy. In an SAP BTP, Cloud Foundry Environment, provide an optional <locationID> in plaintext. Internally, the value is converted to base64 encoding. This value overrides the proxyPassword connection property. In an SAP BTP, Neo Environment, either proxyScpAccount or proxyUsername must be specified. <subaccount> is mandatory and <locationID> is optional. Both values are entered as plaintext strings and are internally converted to base64 encoding. This value overrides the proxyUsername connection property. |
|
SQL_SQLDBC_PROXY_USERID |
SQLCHAR |
Specifies the proxy user name (for METHOD 02 authentication). |
|
SQL_SQLDBC_PROXY_PASSWORD |
SQLCHAR |
Specifies the proxy password (for METHOD 02 authentication). When using the SAP HANA Cloud Connector, this field is used to provide the SAP HANA Cloud Connector location ID value. |
|
SQL_SQLDBC_SET_CLIENTINFO_KEY |
SQLCHAR |
Sets the client information key that is used with the SQL_SQLDBC_GET_CLIENTINFO_VALUE or SQL_SQLDBC_SET_CLIENTINFO_VALUE attribute. |
|
SQL_SQLDBC_SET_CLIENTINFO_VALUE |
SQLCHAR |
Sets the client information value for the key specified by the SQL_SQLDBC_SET_CLIENTINFO_KEY attribute. |
|
SQL_SQLDBC_SHOW_CATALOGS |
SQLULEN |
Tells the ODBC driver whether SQL catalogs are visible. The default is FALSE. |
|
SQL_SQLDBC_SPATIALTYPES |
SQLULEN |
Specifies the spatial type returned for ST_POINT and GT_GEOMETRY columns. This attribute can be specified as follows:
|
ODBC Standard Connection Attributes Supported by the SAP HANA ODBC Driver
|
Connection Attribute |
Type |
Description |
|---|---|---|
|
SQL_ATTR_CURRENT_CATALOG |
SQLCHAR |
Retrieves the database name of the current connection. This attribute cannot be changed. |
|
SQL_ATTR_TXN_ISOLATION |
SQLUINTEGER |
Specifies the transaction isolation level for the connection. The transaction isolation level can be set as follows:
The default transaction isolation level is 1. |
|
SQL_ATTR_AUTOCOMMIT |
SQLUINTEGER |
Specifies the auto commit mode. The auto commit mode can be set as follows:
With SQL_AUTOCOMMIT_OFF the driver uses manual commit mode. The application must explicitly commit or roll back transactions with SQLEndTran. With SQL_AUTOCOMMIT_ON the driver uses auto commit mode. Each statement is committed immediately after it is executed. This is the default. Any open transactions on the connection are committed when SQL_ATTR_AUTOCOMMIT is set to SQL_AUTOCOMMIT_ON. |
|
SQL_ATTR_LOGIN_TIMEOUT |
SQLUINTEGER |
Specifies the login timeout. The value corresponds to the number of seconds to wait for a login request to complete before returning to the application. The driver returns an error back to the application if it cannot complete the login within a given time. The default setting is 0. That means the timeout is disabled and a connection attempt will wait indefinitely. |
|
SQL_ATTR_TRACE |
SQLUINTEGER |
Specifies ODBC tracing. The ODBC tracing can be set as follows:
The default setting is SQL_OPT_TRACE_OFF. When SQL_ATTR_TRACE is set to SQL_OPT_TRACE_ON the Driver Manager writes each ODBC function call to the trace file. |
|
SQL_ATTR_TRACEFILE |
SQLCHAR |
Specifies the ODBC tracing file. The ODBC driver manager writes ODBC function calls to the specified tracing file if SQL_ATTR_TRACE is set to SQL_OPT_TRACE_ON. |
|
SQL_ATTR_PACKET_SIZE |
SQLUINTEGER |
Specifies the network packet size in bytes. The default packet size is 1 MB. |
Remarks
ODBC applications can use the connection attributes, SQL_SQLDBC_SET_CLIENTINFO_KEY and SQL_SQLDBC_SET_CLIENTINFO_VALUE to set the client info key/value pairs to the server using the ODBC function, SQLSetConnectAttr. The driver manager caches the attributes if they are set before calling the SQLDriverConnect or SQLConnect and applies the attributes to the ODBC driver after it is loaded. If the key/value pairs are APPLICATION ID and APPLICATIONUSER, these key/value pairs must be set before calling the SQLDriverConnect or SQLConnect function. How to cache and apply the attributes depends on the individual ODBC driver manager. There are some limitations regarding to these connection attributes on Microsoft Windows with the Microsoft ODBC driver manager and on UNIX with the unixODBC driver manager.
Microsoft Windows:The driver manager only caches one set of the key/value pairs and the last set is applied to the ODBC driver. Therefore, only one of the APPLICATION ID or APPLICATIONUSER can be set through SQLSetConnectAttr per connection. If the application requires both the APPLICATION ID and APPLICATIONUSER, they must be supplied through the connection string on Microsoft Windows.
unixODBC:The unixODBC driver caches all the client info key/value pairs if they are set before calling SQLDriverConnect or SQLConnect, but the driver manager applies the attributes to the driver in reverse order. Therefore, the application must call SQLSetConnectAttr with the attribute, SQL_SQLDBC_SET_CLIENTINFO_VALUE first, then call the API for the SQL_SQLDBC_SET_CLIENTINFO_KEY for each pair of client info key/values.