skip to main content
Using the ODBC Client : Connecting Using a Connection String : DSN-less Connections in Linux and UNIX
 

DSN-less Connections in Linux and UNIX

Connections to a data source can be made via a connection string without referring to a data source name (DSN-less connections). This is accomplished by specifying the "DRIVER=" instead of the "DSN=" keyword in a connection string, as outlined in the ODBC specification. For this to work on Linux and UNIX, a file called odbcinst.ini must exist when the driver encounters DRIVER= in a connection string.
By default, Setup installs a sample odbcinst.ini file in the same location as the sample odbc.ini file, which is in the product installation directory. See Configuring the System Information File for an explanation of the odbc.ini file. The environment variable ODBCINST, recognized by the ODBC Client, must be set to point to the fully qualified path name of the odbcinst.ini file.
For example, to point to the default location of the file in the C shell, you set this variable as follows:
setenv ODBCINST /opt/oaodbc810/client/odbcinst.ini
In the Bourne or Korn shell, you would set it as:
ODBCINST=/opt/oaodbc810/client/odbcinst.ini;export ODBCINST
If the ODBCINST variable is not set, the driver looks in the user’s home directory for a file named odbcinst.ini. If the driver does not find the file, it returns the message:
HY000 - "ODBCINST.INI is not available in the directory pointed to by the ODBCINST environment variable (or the current user's HOME directory) and therefore DSN-Less connections cannot be made."
The following is a sample odbcinst.ini.
[ODBC Drivers]
DataDirect OpenAccess SDK 8.1 = Installed
 
[DataDirect OpenAccess SDK 8.1]
APILevel=1
ConnectFunctions=YYN
Driver=ivoacs27.so
DriverODBCVer=3.52
FileUsage=0
SQLLevel=1