Defining an ODBC Data Source on Windows
The following sections describe how to create a DSN for an InterSystems database on Windows, either via the Control Panel or by creating a file DSN:
Creating a DSN with the ODBC Data Source Administrator
To create a DSN, you can use the Windows ODBC Data Source Administrator to access the InterSystems ODBC Data Source Setup dialog box:
-
In the Windows Control Panel, select Administrative Tools and click the ODBC Data Sources icon (the actual icon name may vary depending on your version of Windows; see “Selecting the Correct ODBC Data Source Administrator Version” below).
-
In the Windows ODBC Data Source Administrator dialog, select the User DSN tab and click the Add... button.
-
Select InterSystems IRIS ODBC for the ODBC 2.5 driver or InterSystems IRIS ODBC35 for the ODBC 3.5 driver, and click the Finish button.
The following illustration shows an instance of the InterSystems ODBC Data Source Setup dialog box with all required fields filled in:
The fields are listed below and are required unless otherwise specified:
-
Name — Specifies the user-defined name of the DSN.
-
Description — Optional. Provides user-defined information about the DSN.
-
Host IP Address — Specifies the IP address to be used by the ODBC connection in dotted decimal or dotted quad form, such as “127.0.0.1”.
-
Host Port Number — Specifies the port to be used by the ODBC connection (see “DefaultPort” in the Configuration Parameter File Reference).
-
Namespace — Specifies the namespace to use as the ODBC data source.
-
Authentication Method — Select one of the following options, depending on the security used for this database. For detailed information on these options, see Authentication Guide.
-
Password — authenticate with standard username and password.
-
Password with SSL/TLS — authenticate using an SSL/TLS-protected connection (see TLS Guide).
-
Kerberos — authenticate with Kerberos (see Kerberos Authentication). For this option, also specify the following settings:
-
Connection Security Level — Select Kerberos, Kerberos with Packet Integrity, or Kerberos with Encryption, as appropriate (see the Client/Server section of About Kerberos and the Access Modes).
-
Service Principal Name — Specify the name of the server to be used as a Kerberos principal.
-
-
-
User Name — Optional. Specifies the username to be used by the ODBC connection. By default, this is _SYSTEM (not case-sensitive).
-
Password — Optional. Specifies the password to be used by the ODBC connection. For the default username, the password is SYS (must be all upper case).
-
ODBC Log — Optional. If selected, specifies the creation of a log file of ODBC client driver activities for all InterSystems DSNs. This log is for troubleshooting; you should not turn logging on during normal operation as it will dramatically slow down ODBC performance. See “ODBC Logging on Windows” for more information.
-
Static Cursors — Optional. If selected, enables the InterSystems ODBC client driver’s static cursor support. If this flag is off, then the cursor support provided by the ODBC Cursor Library will be used. In general, this flag should be off unless you have a specific reason for not using the ODBC Cursor Library.
-
Disable Query Timeout — Optional. If selected, causes the ODBC client driver to ignore the value of the ODBC query timeout setting.
The ODBC query timeout setting specifies how long a client should wait for a specific operation to finish. If an operation does not finish within the specified time, it is automatically cancelled. The ODBC API provides functions to set this timeout value programmatically. Some ODBC applications, however, hard-code this value. If you are using an ODBC application that does not allow you to set the timeout value and the timeout value is too small, you can use the Disable Query Timeout option to disable timeouts.
-
Use Locale Decimal Symbol — Optional. When selected, specifies the use of the current locale's decimal separator; not checking this sets the decimal separator in the process to a period (".") regardless of the locale. This value can have an affect when the ODBC connection is interoperating with an application that uses the decimal separator as defined for the current locale.
-
Unicode SQL Types — Optional. This functionality is only relevant if you are working with a multibyte character set, such as in Chinese, Hebrew, Japanese, or Korean locales. If you are only using single-byte character set data, do not select this check box. If selected, this option turns on reporting of a Unicode SQL type (SQL_WVARCHAR (-9) SQLType) for string data. This allows some Microsoft applications to allocate the properly sized buffers to hold multibyte data.
If an application encounters a “SQL data type out of range” error from the Microsoft Driver Manager using SQLBindParameter, it can be caused by having selected this check box.
After you have created the DSN, you can use the Test Connection button to see if your data source is working correctly.
The Ping button attempts to ping the DSN host machine for the number of times specified in the #Times field. A popup window will display information on ping success or failure.
Windows also offers a set of Power Shell commands for manipulating DSNs from the command line. For details, see the Power Shell documentation for Windows Data Access Components (WDAC).
Selecting the Correct ODBC Data Source Administrator Version
To configure user DSNs on 64-bit Windows, use the Windows Control Panel ODBC Administrator for both 32- and 64-bit programs.
To configure system DSNs for a 32-bit program, run %SystemRoot%\SysWow64\odbcad32.exe.
Using File DSNs and DSN-less Connections
DSN information is typically stored in the Windows Registry (under [HKLM\SOFTWARE\ODBC]), but you can also specify connection information in a file DSN (a text file with extension .dsn).
A file DSN can be created with either the ODBC Data Source Administrator (from the File DSN tab) or a standard text editor. For detailed information, see the Microsoft support siteOpens in a new tab (search on "file DSN").
The file DSN can specify the name of an existing DSN to use, for example:
[ODBC]
DSN=InterSystems ODBC Sample Code
or it can specify a set of key-value pairs that specify the same connection information as a standard registry entry.
A file DSN is invoked by a call to SQLDriverConnect.
File DSNs are typically stored in \Program Files\Common Files\ODBC\Data Sources, but you can use the File DSN tab in the ODBC Data Source Administrator to define a different default location.
ODBC Connection Strings
SQLDriverConnect takes a connection string argument that can specify connection information in three different ways:
Specifies the name of a regular DSN in the registry. For example:
"DSN=ODBC Samples;UID=myUsername;PWD=;"
Specifies a file DSN rather than a registry entry. For example:
"FILEDSN=c:\ODBC_Samples.dsn;UID=myUsername;PWD=;"
Defines all connection information directly in the connection string. For example:
"Driver=InterSystems ODBC Driver;Server=127.0.0.1;Port=51774;Database=USER;UID=myUsername;PWD="