Connecting to a Data Source Using a Connection String

If you want to use a connection string for connecting to a database, or if your application requires it, you must specify either a DSN (data source name), a File DSN, or a DSN-less connection in the string. The difference is whether you use the DSN=, FILEDSN=, or the DRIVER= keyword in the connection string, as described in the ODBC specification. A DSN or FILEDSN connection string tells the driver where to find the default connection information. Optionally, you may specify attribute=value pairs in the connection string to override the default values stored in the data source.

The DSN connection string has the form:

DSN=data_source_name[;attribute=value[;attribute=value]...] 

The FILEDSN connection string has the form:

FILEDSN=filename.dsn[;attribute=value[;attribute=value]...] 

The DSN-less connection string specifies a driver instead of a data source. All connection information must be entered in the connection string because there is no data source storing the information.

The DSN-less connection string has the form:

DRIVER=[{]driver_name[}][;attribute=value[;attribute=value]
...] 

Table 11-1 gives the long and short names for each attribute, as well as a description. You can specify either long or short names in the connection string. Connection string attribute names are the same as the option names on the driver Setup dialog box tabs unless otherwise noted. The connection string attribute name does not have spaces between the words. For example, the connection string attribute name ApplicationUsingThreads is equivalent to the option name Application Using Threads.

The defaults listed in the table are initial defaults that apply when no value is specified in either the data source definition or in the connection string. If you specified a value for the attribute when configuring the data source, that value is the default.

An example of a DSN connection string with overriding attribute values for Informix is:

DSN=INFORMIX TABLES;DB=PAYROLL 

A FILEDSN connection string is similar except for the initial keyword:

FILEDSN=Informix.dsn;DB=DBPAYROLL 

A DSN-less connection string must provide all necessary connection information:

DRIVER=DataDirect 5.3 Informix; 
DB=PAYROLL;UID=JOHN;PWD=XYZZY 
 

Table 11-1. Informix Connection String Attributes 
Attribute
Description
ApplicationUsing
Threads (AUT)
ApplicationUsingThreads={0 | 1}. Determines whether the driver works with multi-threaded applications.
When set to 1 (the initial default), the driver is thread-safe and is ensured to work with multi-threaded applications.
When using the driver with single-threaded applications, you can set this option to 0 to avoid additional processing required for ODBC thread-safety standards.   
This attribute can affect performance. See "Performance Considerations" for details.
CancelDetect
Interval (CDI)
CancelDetectInterval={0 | 5 | 10 | 30 | 60}. A value in seconds that determines how often the driver checks whether a query has been canceled using SQLCancel.
If the driver determines that SQLCancel has been issued, the query is canceled. This attribute determines whether long-running queries in threaded applications are canceled if the application issues a SQLCancel. If set to 0 (the initial default), queries are not canceled even if SQLCancel is issued.
For example, if CancelDetectInterval is set to 5, then for every pending request, the driver checks every five seconds to see whether the application has canceled execution of the query using SQLCancel.
This attribute can affect performance. See "Performance Considerations" for details.
CursorBehavior (CB)
CursorBehavior={0 | 1}. Determines whether cursors will be preserved or closed at the end of each transaction.
When set to 0, cursors will be closed at the end of each transaction.
When set to 1 (the initial default), cursors will be held at the current position when the transaction ends. This value may slow the performance of your database operations.
Database (DB)
The name of the database to which you want to connect.
The equivalent Setup dialog box option is Database Name.
DataSourceName (DSN)
A string that identifies an Informix data source configuration. Examples include Accounting or INFORMIX-Serv1.
EnableInsert
Cursors (EIC)
EnableInsertCursors={0 | 1}. Determines whether the driver can use Insert cursors during inserts governed by parameters.
When set to 0, the driver does not use Insert cursors.
When set to 1 (the initial default), the driver uses Insert cursors.
GetDBListFrom
Informix (GDBLFI)
GetDBListFromInformix={0 | 1}. Determines whether the driver requests the database list to be returned from the Informix server or from the database list that the user entered at driver setup.
When set to 0, the driver uses the list that was entered by the user at driver setup.
When set to 1 (the initial default), the driver requests the database list from the Informix server.
HostName (HOST)
The name of the machine on which the Informix database resides.
IANAAppCodePage (IACP)

For a list of valid values for this attribute, refer to "Values for the Attribute IANAAppCodePage" in the DataDirect Connect for ODBC and Connect XE for ODBC Reference. You need to specify a value for this attribute if your application is not Unicode-enabled and/or if your database character set is not Unicode (refer to "Internationalization, Localization, and Unicode" in the DataDirect Connect for ODBC and Connect XE for ODBC Reference for details). The value you specify must match the database character encoding and the system locale.
The Driver Manager checks for the value of IANAAppCodePage in the following order:
  • In the connection string
  • In the Data Source section of the system information file (odbc.ini)
  • In the ODBC section of the system information file (odbc.ini)
If no IANAAppCodePage value is found, the driver uses the default value of 4 (ISO 8859-1 Latin-1).
LogonID (UID)
Your user name as specified on the Informix server.
The equivalent Setup dialog box option is Default User Name.
Password (PWD)
A password.
Protocol (PRO)

Protocol={olsocspx | olsoctcp | onsocspx | onsoctcp | seipcpip | sesocspx | sesoctcp}. Specifies the protocol used to communicate with the server.
The equivalent Setup dialog box option is Protocol Type.
ServerName
(SRVR)
The name of the Informix server.
Service (SERV)

The name of the service as it appears in the services file on the host machine. This service is assigned by the system administrator.
The equivalent Setup dialog box option is Service Name.
TrimBlankFrom
IndexName (TBFIN)
TrimBlankFromIndexName={0 | 1}. Determines whether the leading space is trimmed from a system-generated index name. This option is provided to address problems with applications that cannot process a leading space in index names.
When set to 0, the driver does not trim the space.
When set to 1 (the initial default), the driver trims the leading space.
UseDefaultLogin (UDL)

UseDefaultLogin={0 | 1}. Determines from where the logon information is read.
When set to 0 (the initial default), logon information is read from the Windows Registry, the connection string, or the Logon to Informix dialog box.
When set to 1, the Logon ID and Password are read directly from the Informix registry.