Neoview Workload Management Services Guide (R2.3)

The service name that you set in the ODBC Administrator applies to queries that run in the data
source. A service name that is set in a JDBC or ODBC client application or in an NCI session
takes precedence over the setting in the ODBC Administrator.
Setting the Service in the MXODSN File on a Linux or UNIX Workstation
On a Linux or UNIX workstation, you can set the service name for a client data source in the
MXODSN file. Add a ServiceName entry at the DS level as shown in boldface below:
[TDM_Default_DataSource]
Description = Default Data Source
Catalog = CAT
Schema = SCH
DataLang = 0
FetchBufferSize = SYSTEM_DEFAULT
Server = TCP:1.2.3.4:18650
SQL_ATTR_CONNECTION_TIMEOUT = SYSTEM_DEFAULT
SQL_LOGIN_TIMEOUT = SYSTEM_DEFAULT
SQL_QUERY_TIMEOUT = NO_TIMEOUT
ServiceName = MY_SERVICE
ReplacementCharacter = ?
The service name that you set in the MXODSN file applies to queries that run in the data source.
A service name that is set in a JDBC or ODBC client application or in an NCI session takes
precedence over the setting in the MXODSN file.
Using the SQLSetConnectAttr() Function to Associate Queries With a Service
In an ODBC application, you can use the SQLSetConnectAttr() function to set a service for
the queries in the application. In the SQLSetConnectAttr() function, set the attribute argument
to 1030 and the value pointer to the service name:
SQLSetConnectAttr( hdbc, 1030, "salesqueries", SQL_NTS);
In the previous example, WMS assigns all subsequent queries in the ODBC application to the
SALESQUERIES service.
The SQLSetConnectAttr() setting takes precedence over the service-name setting in the client
data source. However, a SET SERVICE setting in the application takes precedence over the
SQLSetConnectAttr() setting.
To get the service name that is in effect for an ODBC application, use the SQLGetConnectAttr()
function and set the attribute argument to 1030, the value pointer to a variable for the service
name, and the buffer length to 128:
SQLGetConnectAttr( hdbc, 1030, servicename, 128, SQL_NTS);
For more information about using the ODBC driver, see the Neoview ODBC Drivers Manual.
Using the setServiceName() Method to Associate Queries With a Service
In a JDBC application, you can use the setServiceName() method of the
com.hp.t4jdbc.HPT4Connection class to set a service for the queries in the application:
setServiceName("salesqueries");
In the previous example, WMS assigns all subsequent queries in the JDBC application to the
SALESQUERIES service.
The setServiceName() setting takes precedence over the service-name setting in the client
data source. However, a SET SERVICE setting in the application takes precedence over the
setServiceName() setting.
To get the service name that is in effect for a JDBC application, use the getServiceName()
method of the com.hp.t4jdbc.HPT4Connection class:
String serviceName = getServiceName();
Using the SQLSetConnectAttr() Function to Associate Queries With a Service 37